Advertisement
PineCoders

No Repaint

Aug 28th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. //@version=4
  2. study("", "", true)
  3. repaint = input(true)
  4.  
  5. greenCandle = (close > open)
  6. redCandle = (close < open)
  7. greenCandle1 = (close[1] > open)
  8. redCandle1 = (close[1] < open)
  9. longEma = ema(close, 21)
  10.  
  11. enterVol = volume > (volume[1] * 2)
  12. exitVol = volume[1] > (volume[2] * 2)
  13. shortVol = volume > (volume[1] * 2)
  14.  
  15. enterLong = greenCandle and enterVol and longEma
  16. exitLong = redCandle and redCandle1 and exitVol
  17. enterShort = redCandle and redCandle1 and shortVol
  18.  
  19. long = greenCandle and enterVol and longEma
  20. short = redCandle and redCandle1 and shortVol
  21.  
  22. ofst = repaint or not barstate.islast ? 0 : 1
  23. pos = 0.0
  24. pos:= long? 1 : short? -1 : pos[1]
  25. longCond = (long and pos[1]!= 1)[ofst]
  26. shortCond = (short and pos[1]!= -1)[ofst]
  27.  
  28.  
  29. long_exit = (redCandle and redCandle1 and exitVol and pos[1]==1)[ofst]
  30.  
  31. if long_exit
  32. pos:=0
  33.  
  34. // Chart Plot & Alerts
  35. plotshape(longCond, color=color.green, style=shape.triangleup, text="Buy" , location=location.belowbar, transp=0, offset=0, size=size.tiny)
  36. plotshape(shortCond, color=color.red, style=shape.triangledown, text="Sell", location=location.abovebar, transp=0, offset=0, size=size.tiny)
  37. alertcondition(longCond , title="Enter Long" )
  38. alertcondition(shortCond, title="Enter Short")
  39.  
  40. plotshape(long_exit, color=color.purple, style=shape.xcross, location=location.abovebar, transp=0, offset=0, size=size.tiny)
  41. alertcondition(long_exit , title="Exit Long" )
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement