Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. //@version=4
  2. study("Poor Man's Cumulative Tick", shorttitle="Poor Man's Cumulative Tick", overlay=false)
  3.  
  4. travel = ((high-low)*2-abs(open-close))
  5. direction = (close>open?1:-1)
  6. scale = sma(high-low,1000)
  7. relativevol = volume/sma(volume,1000)*scale
  8. midpoint = travel*direction
  9.  
  10. op = midpoint + relativevol * direction
  11. cl = midpoint - relativevol * direction
  12. hi = op+(high-max(open,close))*scale
  13. lo = cl-(min(open,close)-low)*scale
  14.  
  15. sessionChanged() =>
  16. hd = change(hour)
  17. (hd >= 0 and hd < 2) or hd == -23 ? 0 : 1
  18.  
  19. cumBar(value) =>
  20. cumVal = 0.0
  21. cumVal := sessionChanged() ? 0 : value + nz(cumVal[1],0)
  22.  
  23. moveUp = close > open
  24.  
  25. data = cumBar(cl)
  26.  
  27. c = data>0?(moveUp?color.blue:#2196F3AA):(moveUp?#FFEB38AA:color.yellow)
  28.  
  29. plot(data,title="Cumulative Tick",linewidth=2, style=plot.style_columns, color=c)
  30.  
  31. plotshape(moveUp, title="Advancing", style=shape.triangleup, color=color.blue, location=location.top)
  32. plotshape(not moveUp, title="Declining", style=shape.triangledown, color=color.yellow, location=location.bottom)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement