Advertisement
JustUncleL

My RSI Strategy

Jan 29th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. //@version=2
  2. strategy("My RSI Strategy", overlay=false)
  3. length = input( 11 )
  4. overSold = input( 30 )
  5. overBought = input( 70 )
  6. price = close
  7.  
  8. vrsi = rsi(price, length)
  9. plot(vrsi,color=fuchsia,linewidth=2,transp=20)
  10. hline(overSold,linewidth=2,color=gray)
  11. hline(overBought,linewidth=2,color=gray)
  12.  
  13. // Check OverBought with no Oversold and Visa Versa
  14. xLong = crossover(vrsi, overBought) ? 1 : crossunder(vrsi, overSold)? 0 : nz(xLong[1])
  15. xShort = crossover(vrsi, overBought) ? 0 : crossunder(vrsi, overSold)? 1 : nz(xShort[1])
  16.  
  17. // Count bars after OverBought/OverSold condition
  18. Long = xLong ? na(Long[1]) ? 1 : Long[1]+1 : 0
  19. Short = xShort ? na(Short[1]) ? 1 : Short[1]+1 : 0
  20.  
  21.  
  22. // Alarm Occours on the 1st Crossover/under, without any subsequent opposite cross.
  23. plot(Long==1?100:0, title='Buy Alert', color=green, transp=0, linewidth=1)
  24. plot(Short==1?100:0, title='Sell Alert', color=red, transp=0, linewidth=1)
  25.  
  26.  
  27. if (not na(vrsi))
  28. if (Short==1)
  29. strategy.entry("SHORTLE", strategy.short, comment="SHORTLE")
  30. if (Long==1)
  31. strategy.entry("LONGSE", strategy.long, comment="LONGSE")
  32.  
  33. //plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement