TradingView
boitoki
8 Th01 2022 14:29

Pivots library 

USD/JPYOANDA

Mô tả

Library "Pivots"
TODO: add library description here

pivots(_type, _open, _high, _low, _clsoe) Calculates the pivot point and returns its value.
  Parameters:
    _type: Specifies the type of pivot point.
    _open: The open price
    _high: The high price
    _low: The low price
    _clsoe: The close price
  Returns: Returns the value of the calculated pivot point as a tuple.

cpr(_high, _low, _clsoe) Calculate the Central Pivot Range
  Parameters:
    _high: The high price
    _low: The low price
    _clsoe: The close price
  Returns: Returns the values as a tuple.

htf_ohlc(_htf) Calculate the HTF values
  Parameters:
    _htf: Resolution
  Returns: Returns the values as a tuple.

Phát hành các Ghi chú

Added sample codes.

Phát hành các Ghi chú

v3: Added HTF sample.

Phát hành các Ghi chú

v4: Added pivot types ('Classic', 'DM', 'Camarilla', 'Expected Pivot Points').

Phát hành các Ghi chú

v5

- Added a pivot types "Floor" and "Tom DeMark's Pivot"

Phát hành các Ghi chú

v6
Added "PP only" options.

Phát hành các Ghi chú

v7

added a type 'HL2'

Phát hành các Ghi chú

v8

added a type "Zone Analysis"

Phát hành các Ghi chú

v9

Phát hành các Ghi chú

v10

Phát hành các Ghi chú

v11
added an option "OC2"
Bình luận
LDJP
Great.
Mupsje
Hi I noticed some warnings.
Love your coding btw.

I changed it to get rid of it.
please change it. so you can update your code.
line 145 etc.

f_htf_ohlc (_htf) => var htf_o = 0., var htf_h = 0., var htf_l = 0., htf_c = close var htf_ox = 0., var htf_hx = 0., var htf_lx = 0., var htf_cx = 0. bool i_htf = ta.change(time(_htf)) != 0 // Check if there's a change in the higher timeframe if i_htf htf_ox := htf_o, htf_o := open htf_hx := htf_h, htf_h := high htf_lx := htf_l, htf_l := low htf_cx := htf_c[1] else htf_h := math.max(high, htf_h) htf_l := math.min(low, htf_l) [htf_ox, htf_hx, htf_lx, htf_cx, htf_o, htf_h, htf_l, htf_c]

And the render also

f_render_candle (htf) => bool i_htf = ta.change(time(htf)) != 0 time_x11 = ta.valuewhen(i_htf, time, 1) time_x1 = ta.valuewhen(i_htf, time, 0) offset = math.round(ta.change(time)) time_x2 = (2 * time_x1 - time_x11) - offset // Determine candle colors based on the current and previous closes color0 = O0 < C0 ? color.green : color.red color01 = color.new(color0, 90) color1 = O1 < C1 ? color.green : color.red color11 = color.new(color1, 90) var box oc = na, var box hl = na // Check if there's a change in the higher timeframe if i_htf // Create boxes for open/close and high/low and set their properties oc := box.new(time_x1, O1, time_x2, C1, bgcolor=color.new(color0, 90), border_color=color.new(color0, 30), xloc=xloc.bar_time) hl := box.new(time_x1, H1, time_x2, L1, bgcolor=color.new(color0, 90), border_color=color.new(color0, 30), border_style=line.style_dotted, xloc=xloc.bar_time) true else // Update the existing boxes with the latest values box.set_top(oc, math.max(O0, C0)) box.set_bottom(oc, math.min(O0, C0)) box.set_bgcolor(hl, color.new(color0, 90)) box.set_border_color(hl, color.new(color01, 30)) box.set_top(hl, H0) box.set_bottom(hl, L0) box.set_bgcolor(oc, color.new(color0, 90)) box.set_border_color(oc, color.new(color01, 30)) true // Call the rendering function with the specified higher timeframe type f_render_candle(i_htf_type)
boitoki
@Mupsje, Thank you . It's updated in the new version.
Papadaulat
Hello, Not showing S4, S5. R4 & R5. How to display please.
MatthewWen
Hello, I have the problem of overlapping the screen after copying and pasting. Can you tell me how to solve it? Thank you
boitoki
@Eason_yi, Hi thank you.
Can you rewrite that code so that it doesn't draw the lines when the value is 0?

For example, using line.new:
if R5 > 0
line.new(...)

For example, using plot:
plot(R5 > 0 ? R5 : na, ...)
odcheban
Thank You!
boitoki
@odcheban, You're welcome!
ne146xx
Hey, really cool script. Thank you for this.
Maybe in a future update, can we please have the option to modify the color of the lines and text?
Thank you once again. Works really well :)
boitoki
@ne146xx, Hi thanks!
This library provides only numbers. You can set the style, etc., in the scripts that are imported.
Thêm nữa