Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. //@version=4
  2. maxBarsBack = 5000
  3. study("JM_PPI", overlay = true, max_bars_back = maxBarsBack)
  4.  
  5. // ||-------------------------------------------------------------------------||
  6. // || Pseudo Array ATHs/ATLs: (ID)
  7. // |{-------------------------------------------------------------------------<•
  8. // || variable initialization:
  9. var float ath = 0.0, var float atl = 10e20,
  10. var line lineH = na, var line lineL = na,
  11. var line lineLTH = na, var line lineHTL = na,
  12. var line secondaryH = na, var line secondaryL = na,
  13. var line secondaryLTH = na, var line secondaryHTL = na,
  14. var line uptrend = na, var line downtrend = na
  15. var string Event = "", var string secondaryHigh = ""
  16. // |{-------------------------------------------------------------------------<•
  17.  
  18. ath := max(ath, high)
  19. atl := min(atl, low)
  20.  
  21. // Bars on chart count
  22. var int BarCount = 0
  23. BarCount := BarCount + 1
  24.  
  25. if change(ath)
  26. lineH := line.new(time, high, time + (time - time[1]), high, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.red, width = 4)
  27. lineLTH := line.new(time, low, time + (time - time[1]), low, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.orange, width = 2)
  28. Event := "Event_ATH"
  29.  
  30. if change(atl)
  31. lineL := line.new(time, low, time + (time - time[1]), low, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.green, width = 4)
  32. lineHTL := line.new(time, high, time + (time - time[1]), high, xloc = xloc.bar_time, style = line.style_dotted, extend = extend.both, color = color.blue, width = 2)
  33. Event := "Event_ATL"
  34.  
  35. for i = 0 to BarCount - 1
  36. if (Event == "Event_ATL" and high >= line.get_y1(lineLTH[i]))
  37. line.delete(lineH[i])
  38. line.delete(lineLTH[i])
  39. if (Event == "Event_ATH" and low <= line.get_y1(lineHTL[i]))
  40. line.delete(lineL[i])
  41. line.delete(lineHTL[i])
  42.  
  43. plot(ath, "ATH", color.red, 4, plot.style_line)
  44. plot(atl, "ATL", color.lime, 4, plot.style_line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement