Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study("Pivot Points High Low", shorttitle="Pivots HL", overlay=true)
- lenH = input(title="Length High", type=input.integer, defval=10, minval=1)
- lenL = input(title="Length Low", type=input.integer, defval=10, minval=1)
- mult1 = input(0.5, "Line 1 multiple")
- mult2 = input(1.0, "Line 2 multiple")
- var float zero_pt_five_Hi = na
- var float zero_pt_five_Lo = na
- var float one_pt_Hi = na
- var float one_pt_Lo = na
- fun(src, len, isHigh) =>
- p = nz(src[len])
- isFound = true
- for i = 0 to len - 1
- if isHigh and src[i] > p
- isFound := false
- if not isHigh and src[i] < p
- isFound := false
- for i = len + 1 to 2 * len
- if isHigh and src[i] >= p
- isFound := false
- if not isHigh and src[i] <= p
- isFound := false
- isFound ? p : na
- newHi = fun(high, lenH, true)
- if not na(newHi)
- baseHi = high[lenH]-low[lenH]
- label.new(bar_index[lenH], high[lenH], tostring(high[lenH]) + "\n" + tostring(baseHi * mult1), style=label.style_labeldown, yloc=yloc.abovebar, color=color.lime)
- zero_pt_five_Hi := newHi + baseHi * mult1
- one_pt_Hi := newHi + baseHi * mult2
- newLo = fun(low, lenL, false)
- if not na(newLo)
- baseLo = high[lenL]-low[lenL]
- label.new(bar_index[lenH], low[lenH], tostring(low[lenH]) + "\n" + tostring(baseLo * mult1), style=label.style_labelup, yloc=yloc.belowbar, color=color.red)
- zero_pt_five_Lo := newLo - baseLo * mult1
- one_pt_Lo := newLo - baseLo * mult2
- plot(zero_pt_five_Hi, "Last High", color.green, 2, plot.style_circles, offset = -lenH)
- plot(zero_pt_five_Lo, "Last Low", color.red, 2, plot.style_circles, offset = -lenL)
- plot(one_pt_Hi, "1.0 Hi Ext", color.yellow, 2, plot.style_circles, offset = -lenH)
- plot(one_pt_Lo, "1.0 Low Ext", color.orange, 2, plot.style_circles, offset = -lenL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement