Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- //Created by Morreno on SEPTEMBER 28, 2019 For PIPHUNTER MOVEMENT.
- //Update to version 5 by keRLos
- indicator(title="PIP HUNTERSCR STOCH RSI SIGNALL with Alert", shorttitle="PIP HUNTERSCR STOCH RSI SIGNAL with Alert")
- len = input.int(10,"Longitud Estocastico", 1)
- smoothK = input.int(3, minval=1, title="%K Stoch")
- smoothD = input.int(3, minval=1, title="%D Stoch")
- upLine = input.int(90, minval=55, maxval=95, title="Higher band")
- lowLine = input.int(10, minval=5, maxval=45, title="Lower Band")
- sml = input(true, title="Show mid line?")
- 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? - strict criteria - line K - higher/lower high/low - Cross D ?")
- sac = input(false, title="Show Back Ground Highlights When RSI Cross?")
- useCurrentRes = input(true, title="Use Current Chart Resolution?")
- resCustom = input.timeframe(title="Use Different Timeframe? Uncheck Box Above", defval="60")
- //Resolution for Multiple time frames
- res = useCurrentRes ? timeframe.period : resCustom
- //var new
- h1 = upLine
- h2 = lowLine
- inp = input(close)
- //Stoch formula
- k = ta.sma(ta.stoch(inp, high, low, len), smoothK)
- d = ta.sma(k, smoothD)
- outK = request.security(syminfo.tickerid, res, k)
- outD = request.security(syminfo.tickerid, res, d)
- //definitions for Cross
- aboveLine = outK > upLine ? 1 : 0
- belowLine = outK < lowLine ? 1 : 0
- crossUp = (outK[1] < outD[1] and outK[1] < lowLine[1]) and (outK > outD) ? 1 : 0
- crossDn = (outK[1] > outD[1] and outK[1] > upLine[1]) and (outK < outD) ? 1 : 0
- //Definition for Cross that doesn't have to be above or below High and Low line.
- crossUpAll = (outK[1] < outD[1] and outK > outD) ? 1 : 0
- crossDownAll = (outK[1] > outD[1] and outK < outD) ? 1 : 0
- //BackGroound Color Plots
- bgcolor(sbh and aboveLine ? color.new(#FF5252,90) : na)
- bgcolor(sbh and belowLine ? color.new(#4CAF50,90) : na)
- bgcolor(sch and crossUp ? color.new(#4CAF50,40) : na)
- bgcolor(sch and crossDn ? color.new(#FF5252,40) : na)
- alertcondition(crossUp, 'Crossup', 'Oversold')
- alertcondition(crossDn, 'Crossdown', 'Overbought')
- //plots for Cross with no filter
- bgcolor(sac and crossUpAll ? color.new(#4CAF50,40) : na)
- bgcolor(sac and crossDownAll ? color.new(#FF5252,40) : na)
- //Plot main Stochastic
- plot(outK, title="Stoch K", linewidth=1, color=color.green)
- plot(outD, title="Stoch D", linewidth=1, color=color.red)
- //plot(upLine, title= "Banda mayor", style=dashed, linewidth=1, color=#FF5252)
- //plot(lowLine, title= "Banda menor", style=dashed, linewidth=1, color=#4CAF50)
- hline(h1, color=#FF5252, editable=true, linestyle=hline.style_dashed)
- hline(h2, color=#4CAF50, editable=true, linestyle=hline.style_dashed)
- hline(50, color=color.gray, editable=true, linestyle=hline.style_dashed)
- //plot(sml and 50 ? 50 : na, title="Linea Medio", style=dashed, linewidth=1, color=gray)
- //fill(p1, p2, color=silver, transp=70)
- //rsi formula
- src = inp
- rlen = input.int(14, minval=1, title="RSI Length")
- chg = ta.change(src)
- up = ta.rma(ta.max(chg), rlen)
- down = ta.rma(-ta.min(chg), rlen)
- rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
- //Plot secundary rsi
- plot(rsi, title='Enable RSI Band',color=#0000ff, linewidth=1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement