Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study("", "", true)
- repaint = input(true)
- greenCandle = (close > open)
- redCandle = (close < open)
- greenCandle1 = (close[1] > open)
- redCandle1 = (close[1] < open)
- longEma = ema(close, 21)
- enterVol = volume > (volume[1] * 2)
- exitVol = volume[1] > (volume[2] * 2)
- shortVol = volume > (volume[1] * 2)
- enterLong = greenCandle and enterVol and longEma
- exitLong = redCandle and redCandle1 and exitVol
- enterShort = redCandle and redCandle1 and shortVol
- long = greenCandle and enterVol and longEma
- short = redCandle and redCandle1 and shortVol
- ofst = repaint or not barstate.islast ? 0 : 1
- pos = 0.0
- pos:= long? 1 : short? -1 : pos[1]
- longCond = (long and pos[1]!= 1)[ofst]
- shortCond = (short and pos[1]!= -1)[ofst]
- long_exit = (redCandle and redCandle1 and exitVol and pos[1]==1)[ofst]
- if long_exit
- pos:=0
- // Chart Plot & Alerts
- plotshape(longCond, color=color.green, style=shape.triangleup, text="Buy" , location=location.belowbar, transp=0, offset=0, size=size.tiny)
- plotshape(shortCond, color=color.red, style=shape.triangledown, text="Sell", location=location.abovebar, transp=0, offset=0, size=size.tiny)
- alertcondition(longCond , title="Enter Long" )
- alertcondition(shortCond, title="Enter Short")
- plotshape(long_exit, color=color.purple, style=shape.xcross, location=location.abovebar, transp=0, offset=0, size=size.tiny)
- alertcondition(long_exit , title="Exit Long" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement