Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- maxBarsBack = 2000
- study("PPI", overlay = true, max_bars_back = maxBarsBack)
- // ||-------------------------------------------------------------------------||
- // || Pseudo Array ATHs/ATLs: (ID)
- // |{-------------------------------------------------------------------------<•
- // || variable initialization:
- var float ath0 = 0.0, var float atl0 = 10e20,
- var float ath1 = 0.0, var float atl1 = 10e20,
- var float ath2 = 0.0, var float atl2 = 10e20,
- var float aLTH0 = 0.0, var float aHTL0 = 0.0,
- var float aLTH1 = 0.0, var float aHTL1 = 0.0,
- var float aLTH2 = 0.0, var float aHTL2 = 0.0,
- var float _atHighs1 = 0.0, var float _atLows1 = 0.0
- var line line0 = na, var line line0a = na,
- var line line1 = line0[1], var line line1a = line0[1],
- var line line2 = na, var line line2a = na,
- var line line3 = line2[1], var line line3a = line2[1]
- // |{-------------------------------------------------------------------------<•
- ath0 := max(ath0, high)
- ath1 := max(ath1, high)
- ath2 := max(ath2, high)
- aLTH0 := change(ath0) ? low : aLTH0
- aLTH1 := change(ath1) ? low : aLTH1
- aLTH2 := change(ath2) ? low : aLTH2
- atl0 := min(atl0, low)
- atl1 := min(atl1, low)
- atl2 := min(atl2, low)
- aHTL0 := change(atl0) ? high : aHTL0
- aHTL1 := change(atl1) ? high : aHTL1
- aHTL2 := change(atl2) ? high : aHTL2
- if change(ath0)
- //ath1 := ath0
- _atHighs1 := ath0
- ath1 := ath0[1]
- ath2 := ath0[2]
- line0 := line.new(time, high, time + (time - time[1]), high, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.red, width = 3)
- //line0a := line.new(time, low, time + (time - time[1]), low, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.blue, width = 3)
- //line1 := line.new(time, high, time[1] + (time[1] - time[2]), high, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.black, width = 3)
- //line1a := line.new(time, low, time[1] + (time[1] - time[2]), low, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.purple, width = 3)
- label1 = label.new(bar_index, high, "ATH", xloc.bar_index, yloc.abovebar, color.red, label.style_labeldown, color.black, size.tiny)
- if (high > line.get_y1(line0))
- line.new(time, high, time + (time - time[1]), high, xloc = xloc.bar_time, style = line.style_solid, extend = extend.both, color = color.purple, width = 5)
- //line.delete(line0[1])
- //line.delete(line0a[1])
- _atHighs1
- if change(atl0)
- atl1 := atl0
- _atLows1 := atl1
- //line2 := line.new(time, low, time + (time - time[1]), low, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.green, width = 3)
- //line3 := line.new(time, low, time[1] + (time[1] - time[2]), low, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.black, width = 3)
- //line3a := line.new(time, high, time[1] + (time[1] - time[2]), high, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.purple, width = 1)
- //label2 = label.new(bar_index, low, "ATL", xloc.bar_index, yloc.belowbar, color.green, label.style_labelup, color.black, size.tiny)
- _atLows1
- plot(ath0, "ATH", color.red, 4, plot.style_line)
- plot(atl0, "ATL", color.lime, 4, plot.style_line)
- plot(aLTH0, "aLTH", color.red, 2, plot.style_line)
- plot(aHTL0, "aHTL", color.lime, 2, plot.style_line)
- //lenH = input(title="Length High", type=input.integer, defval=10, minval=1)
- //lenL = input(title="Length Low", type=input.integer, defval=10, minval=1)
- //fun(src, len, isHigh, _style, _yloc, _color) =>
- //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
- //if isFound
- //label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)
- //fun(high, lenH, true, label.style_labeldown, yloc.abovebar, color.lime)
- //fun(low, lenL, false, label.style_labelup, yloc.belowbar, color.red)
- //pivot_high = pivothigh(high,left,right)
- //pivot_lows = pivotlow(low, left,right)
- //quick_pivot_high = pivothigh(high,left,quick_right)
- //quick_pivot_lows = pivotlow(low, left,quick_right)
- //level2 = valuewhen(quick_pivot_lows, low[quick_right], 0)
- //level3 = valuewhen(pivot_high, high[right], 0)
- //level4 = valuewhen(pivot_lows, low[right], 0)
- //level5 = valuewhen(pivot_high, high[right], 1)
- //level6 = valuewhen(pivot_lows, low[right], 1)
- //level7 = valuewhen(pivot_high, high[right], 2)
- //level8 = valuewhen(pivot_lows, low[right], 2)
- //plot(level1, "level1")
- //level1_col = close >= level1 ? color.green : color.red
- //level2_col = close >= level2 ? color.green : color.red
- //level3_col = close >= level3 ? color.green : color.red
- //level4_col = close >= level4 ? color.green : color.red
- //level5_col = close >= level5 ? color.green : color.red
- //level6_col = close >= level6 ? color.green : color.red
- //level7_col = close >= level7 ? color.green : color.red
- //level8_col = close >= level8 ? color.green : color.red
- //event = close >= level6
- //since_event = barssince(event)
- //first_event = since_event==1
- //second_event = close < level6
- //since_second_event = barssince(second_event)
- //sec_event = since_second_event==1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement