Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study(title="RSXRSIv2", shorttitle="RSXRSI2", precision=0)
- src = close
- upLine = input(70, minval=50, maxval=90, title="RSI Upper Line Value")
- lowLine = input(30, minval=10, maxval=50, title="RSI Lower Line Value")
- len = input(14, minval=1, title="1st RSI Length")
- lenema1 = input(12, minval=1, title="1st RSI EMA Length")
- len2 = input(14, minval=1, title="2nd RSI Length")
- //lenema2 = input(12, minval=1, title="2nd RSI EMA Length")
- sbh = input(true, title="Show Back Ground Highlights When RSI is Above/Below High/Low Lines")
- sch = input(true, title="Show Back Ground Highlights When RSI Cross")
- sl = input(true, title="Show 'B' and 'S' Letters When RSI Crosses High/Low Line")
- useCurrentRes = input(true, title="1st RSI Use Current Chart Timeframe")
- resCustom = input(title="1st RSI Use Custom Timeframe (Uncheck Box Above)", type=input.resolution, defval="60")
- ssRSI = input(false, title="Show 2nd RSI on Custom Timeframe")
- resCustom2 = input(title="2nd RSI Custom Timeframe", type=input.resolution, defval="D")
- useCurrentRes2 = input(false, title="2nd RSI Timeframe Overide")
- res = useCurrentRes ? timeframe.period : resCustom
- res2 = useCurrentRes2 ? timeframe.period : resCustom2
- up = rma(max(change(src), 0), len)
- down = rma(-min(change(src), 0), len)
- rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
- outRSI = security(syminfo.tickerid, res, rsi)
- up2 = rma(max(change(src), 0), len2)
- down2 = rma(-min(change(src), 0), len2)
- rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))
- outRSI2 = security(syminfo.tickerid, res2, rsi2)
- aboveLine = outRSI > upLine ? 1 : 0
- belowLine = outRSI < lowLine ? 1 : 0
- crossUp = outRSI[1] < lowLine and outRSI > lowLine ? 1 : 0
- crossDn = outRSI[1] > upLine and outRSI < upLine ? 1 : 0
- bgcolor(sbh and aboveLine ? color.red : na, transp=70)
- bgcolor(sbh and belowLine ? color.green : na, transp=70)
- bgcolor(sch and crossUp ? color.lime : na, transp=40)
- bgcolor(sch and crossDn ? color.red : na, transp=40)
- plot(outRSI, title="RSI", linewidth=1, color=color.aqua)
- plot(ssRSI and outRSI2 ? outRSI2 : na, title="2nd RSI - Different Time Frame?", style=plot.style_linebr, linewidth=1, color=color.orange)
- plotchar(sl and crossUp ? crossUp : na, title="Buy Signal", char='B', location=location.bottom, color=color.lime, transp=0, offset=0)
- plotchar(sl and crossDn ? crossDn : na, title="Sell Signal", char='S', location=location.top, color=color.red, transp=0, offset=0)
- showHline = input(true, title='Control Zones', defval=true)
- showHline2 = input(true, title='Mid/OB/OS Levels', defval=true)
- hline(20, color = showHline2 ? #808080 : #00000000)
- hline(80, color = showHline2 ? #808080 : #00000000)
- hline(50, color = showHline2 ? #808080 : #00000000)
- hline(65, color = showHline ? #228B22 : #00000000)
- hline(70, color = showHline ? #228B22 : #00000000)
- hline(30, color = showHline ? #800000 : #00000000)
- hline(45, color = showHline ? #800000 : #00000000)
- //RSIEMA
- out = ema(rsi, lenema1)
- plot(out, title="RSI EMA", color=color.orange, linewidth=1, transp=0)
- //out2 = ema(rsi2, lenema2)
- //plot(outRSI2, title="RSI 2 EMA", color=orange, linewidth=1, transp=0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement