SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //@version=4
  2. maxBarsBack = 2000
  3. study("PPI", overlay = true, max_bars_back = maxBarsBack)
  4.  
  5. //  ||-------------------------------------------------------------------------||
  6. //  ||  Pseudo Array ATHs/ATLs: (ID)
  7. //  |{-------------------------------------------------------------------------<•
  8. //  ||  variable initialization:
  9. var float ath0 = 0.0, var float atl0 = 10e20,
  10. var float ath1 = 0.0, var float atl1 = 10e20,
  11. var float ath2 = 0.0, var float atl2 = 10e20,
  12. var float aLTH0 = 0.0, var float aHTL0 = 0.0,
  13. var float aLTH1 = 0.0, var float aHTL1 = 0.0,
  14. var float aLTH2 = 0.0, var float aHTL2 = 0.0,
  15. var float _atHighs1 = 0.0, var float _atLows1 = 0.0
  16. var line line0 = na, var line line0a = na,
  17. var line line1 = line0[1], var line line1a = line0[1],
  18. var line line2 = na, var line line2a = na,
  19. var line line3 = line2[1], var line line3a = line2[1]
  20. //  |{-------------------------------------------------------------------------<•
  21.  
  22. ath0 := max(ath0, high)
  23. ath1 := max(ath1, high)
  24. ath2 := max(ath2, high)
  25. aLTH0 := change(ath0) ? low : aLTH0
  26. aLTH1 := change(ath1) ? low : aLTH1
  27. aLTH2 := change(ath2) ? low : aLTH2
  28. atl0 := min(atl0, low)
  29. atl1 := min(atl1, low)
  30. atl2 := min(atl2, low)
  31. aHTL0 := change(atl0) ? high : aHTL0
  32. aHTL1 := change(atl1) ? high : aHTL1
  33. aHTL2 := change(atl2) ? high : aHTL2
  34.  
  35. if change(ath0)
  36.     //ath1 := ath0
  37.     _atHighs1 := ath0
  38.     ath1 := ath0[1]
  39.     ath2 := ath0[2]
  40.     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)
  41.     //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)
  42.     //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)
  43.     //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)
  44.     label1 = label.new(bar_index, high, "ATH", xloc.bar_index, yloc.abovebar, color.red, label.style_labeldown, color.black, size.tiny)
  45.    
  46.     if (high > line.get_y1(line0))
  47.         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)
  48.        
  49.     //line.delete(line0[1])
  50.     //line.delete(line0a[1])
  51.     _atHighs1
  52.  
  53. if change(atl0)
  54.     atl1 := atl0
  55.     _atLows1 := atl1
  56.     //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)
  57.     //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)
  58.     //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)
  59.     //label2 = label.new(bar_index, low, "ATL", xloc.bar_index, yloc.belowbar, color.green, label.style_labelup, color.black, size.tiny)
  60.     _atLows1
  61.    
  62.  
  63.  
  64.  
  65. plot(ath0, "ATH", color.red, 4, plot.style_line)
  66. plot(atl0, "ATL", color.lime, 4, plot.style_line)
  67. plot(aLTH0, "aLTH", color.red, 2, plot.style_line)
  68. plot(aHTL0, "aHTL", color.lime, 2, plot.style_line)
  69.  
  70. //lenH = input(title="Length High", type=input.integer, defval=10, minval=1)
  71. //lenL = input(title="Length Low", type=input.integer, defval=10, minval=1)
  72.  
  73. //fun(src, len, isHigh, _style, _yloc, _color) =>
  74.     //p = nz(src[len])
  75.     //isFound = true
  76.     //for i = 0 to len - 1
  77.         //if isHigh and src[i] > p
  78.             //isFound := false
  79.  
  80.         //if not isHigh and src[i] < p
  81.             //isFound := false
  82.  
  83.     //for i = len + 1 to 2 * len
  84.         //if isHigh and src[i] >= p
  85.             //isFound := false
  86.  
  87.         //if not isHigh and src[i] <= p
  88.             //isFound := false
  89.  
  90.     //if isFound
  91.         //label.new(bar_index[len], p, tostring(p), style=_style, yloc=_yloc, color=_color)
  92.  
  93. //fun(high, lenH, true, label.style_labeldown, yloc.abovebar, color.lime)
  94. //fun(low, lenL, false, label.style_labelup, yloc.belowbar, color.red)
  95.  
  96. //pivot_high = pivothigh(high,left,right)
  97. //pivot_lows = pivotlow(low, left,right)
  98.  
  99. //quick_pivot_high = pivothigh(high,left,quick_right)
  100. //quick_pivot_lows = pivotlow(low, left,quick_right)
  101.  
  102.  
  103. //level2 = valuewhen(quick_pivot_lows, low[quick_right], 0)
  104. //level3 = valuewhen(pivot_high, high[right], 0)
  105. //level4 = valuewhen(pivot_lows, low[right], 0)
  106. //level5 = valuewhen(pivot_high, high[right], 1)
  107. //level6 = valuewhen(pivot_lows, low[right], 1)
  108. //level7 = valuewhen(pivot_high, high[right], 2)
  109. //level8 = valuewhen(pivot_lows, low[right], 2)
  110. //plot(level1, "level1")
  111.  
  112. //level1_col = close >= level1 ? color.green : color.red
  113. //level2_col = close >= level2 ? color.green : color.red
  114. //level3_col = close >= level3 ? color.green : color.red
  115. //level4_col = close >= level4 ? color.green : color.red
  116. //level5_col = close >= level5 ? color.green : color.red
  117. //level6_col = close >= level6 ? color.green : color.red
  118. //level7_col = close >= level7 ? color.green : color.red
  119. //level8_col = close >= level8 ? color.green : color.red
  120.  
  121. //event = close >= level6
  122. //since_event = barssince(event)
  123. //first_event = since_event==1
  124.  
  125. //second_event = close < level6
  126. //since_second_event = barssince(second_event)
  127. //sec_event = since_second_event==1
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top