Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. //@version=3
  2. study("LOM TREND ver2", overlay=true)
  3.  
  4. length = input(title="ATR Period", type=integer, defval=1)
  5. mult = input(title="ATR Multiplier", type=float, step=0.1, defval=10.0)
  6.  
  7. atr = mult * atr(length)
  8.  
  9. longStop = hl2 - atr
  10. longStopPrev = nz(longStop[1], longStop)
  11. longStop := close[1] > longStopPrev ? max(longStop, longStopPrev) : longStop
  12.  
  13. shortStop = hl2 + atr
  14. shortStopPrev = nz(shortStop[1], shortStop)
  15. shortStop := close[1] < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop
  16.  
  17. dir = 1
  18. dir := nz(dir[1], dir)
  19. dir := dir == -1 and close > shortStopPrev ? 1 : dir == 1 and close < longStopPrev ? -1 : dir
  20.  
  21. longColor = green
  22. shortColor = red
  23. //plot
  24. plot(dir == 1 ? longStop : na, title="BuyLine", style=linebr, linewidth=2, color=longColor)
  25. plotshape(dir == 1 and dir[1] == -1 ? longStop : na, title="Buy", style=shape.labelup, location=location.absolute, size=size.normal, text="Buy", transp=0, textcolor = white, color=green, transp=0)
  26.  
  27. plot(dir == 1 ? na : shortStop, title="SellLine", style=linebr, linewidth=2, color=shortColor)
  28. plotshape(dir == -1 and dir[1] == 1 ? shortStop : na, title="Sell", style=shape.labeldown, location=location.absolute, size=size.normal, text="Sell", transp=0, textcolor = white, color=red, transp=0)
  29.  
  30. barcolor(dir == 1 ? green: red)
  31.  
  32. changeCond = dir != dir[1]
  33. alertcondition(longStop, title="Buy", message="Buy!")
  34. alertcondition(longStop, title="Buy", message="Buy!")
  35. alertcondition(longStop, title="Buy", message="Buy!")
  36. alertcondition(shortStop, title="Sell", message="Sell!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement