Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=3
- study("LOM TREND ver2", overlay=true)
- length = input(title="ATR Period", type=integer, defval=1)
- mult = input(title="ATR Multiplier", type=float, step=0.1, defval=10.0)
- atr = mult * atr(length)
- longStop = hl2 - atr
- longStopPrev = nz(longStop[1], longStop)
- longStop := close[1] > longStopPrev ? max(longStop, longStopPrev) : longStop
- shortStop = hl2 + atr
- shortStopPrev = nz(shortStop[1], shortStop)
- shortStop := close[1] < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop
- dir = 1
- dir := nz(dir[1], dir)
- dir := dir == -1 and close > shortStopPrev ? 1 : dir == 1 and close < longStopPrev ? -1 : dir
- longColor = green
- shortColor = red
- //plot
- plot(dir == 1 ? longStop : na, title="BuyLine", style=linebr, linewidth=2, color=longColor)
- 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)
- plot(dir == 1 ? na : shortStop, title="SellLine", style=linebr, linewidth=2, color=shortColor)
- 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)
- barcolor(dir == 1 ? green: red)
- changeCond = dir != dir[1]
- alertcondition(longStop, title="Buy", message="Buy!")
- alertcondition(longStop, title="Buy", message="Buy!")
- alertcondition(longStop, title="Buy", message="Buy!")
- alertcondition(shortStop, title="Sell", message="Sell!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement