Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=2
- strategy("My RSI Strategy", overlay=false)
- length = input( 11 )
- overSold = input( 30 )
- overBought = input( 70 )
- price = close
- vrsi = rsi(price, length)
- plot(vrsi,color=fuchsia,linewidth=2,transp=20)
- hline(overSold,linewidth=2,color=gray)
- hline(overBought,linewidth=2,color=gray)
- // Check OverBought with no Oversold and Visa Versa
- xLong = crossover(vrsi, overBought) ? 1 : crossunder(vrsi, overSold)? 0 : nz(xLong[1])
- xShort = crossover(vrsi, overBought) ? 0 : crossunder(vrsi, overSold)? 1 : nz(xShort[1])
- // Count bars after OverBought/OverSold condition
- Long = xLong ? na(Long[1]) ? 1 : Long[1]+1 : 0
- Short = xShort ? na(Short[1]) ? 1 : Short[1]+1 : 0
- // Alarm Occours on the 1st Crossover/under, without any subsequent opposite cross.
- plot(Long==1?100:0, title='Buy Alert', color=green, transp=0, linewidth=1)
- plot(Short==1?100:0, title='Sell Alert', color=red, transp=0, linewidth=1)
- if (not na(vrsi))
- if (Short==1)
- strategy.entry("SHORTLE", strategy.short, comment="SHORTLE")
- if (Long==1)
- strategy.entry("LONGSE", strategy.long, comment="LONGSE")
- //plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement