SuperJump HTF SuperTrend for Scalping
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SuperJump

//@version=5
indicator("SuperJump HTF SuperTrend for Scalping", shorttitle="SJump ST Scalping" ,  overlay=true)

htf = input.timeframe(title="Higher TimeFrame",defval="15")

Factor=input.float(1.7, minval=1,maxval = 100)
Pd=input.int(14,title="Period", minval=1,maxval = 100) 
LossLevel = input.int(-35, title="Loss Cut")
Topfib3Level = input.int(25, title="1st Defence Line")
Topfib2Level = input.int(14, title="2nd Defence Line")
Topfib1Level = input.int(7, title="3rd Defence Line")

MUp=request.security(syminfo.tickerid,htf,hl2-(Factor*ta.atr(Pd)))
MDn=request.security(syminfo.tickerid,htf,hl2+(Factor*ta.atr(Pd)))
Mclose=request.security(syminfo.tickerid,htf,close)

MTrendUp = 0.0
MTrendDown = 0.0

Tsl = 0.0
MTsl = 0.0
MTslR = 0.0
MTrend = 0.0
Trend = 0.0
LossLine = 0.0


MTrendUp := Mclose[1]>MTrendUp[1]? math.max(MUp,MTrendUp[1]) : MUp
MTrendDown := Mclose[1]<MTrendDown[1]? math.min(MDn,MTrendDown[1]) : MDn


MTrend := Mclose > MTrendDown[1] ? 1: Mclose< MTrendUp[1]? -1: nz(MTrend[1],1)
MTsl := MTrend==1? MTrendUp: MTrendDown
MTslR := MTrend==1? MTrendDown :MTrendUp

TFL1 = MTsl +(MTslR -MTsl)*Topfib1Level /100
TFL2 =MTsl +(MTslR -MTsl)*Topfib2Level /100
TFL3 =MTsl +(MTslR -MTsl)*Topfib3Level /100
LossLine:=MTsl +(MTslR -MTsl)*LossLevel /100

Mlinecolor = MTrend == 1 ? color.green : color.red
mtp = plot(MTsl, color = Mlinecolor , style = plot.style_line , linewidth = 2,title = "HTF SuperTrend")

tfl3p = plot(TFL3, color = color.gray, style = plot.style_line , linewidth = 1,title = "HTF SuperTrend Defence Line1")
tfl2p = plot(TFL2, color = color.gray, style = plot.style_line , linewidth = 1,title = "HTF SuperTrend Defence Line2")
tfl1p = plot(TFL1, color = color.gray, style = plot.style_line , linewidth = 1,title = "HTF SuperTrend Defence Line3")
plot(LossLine, color = color.red, style = plot.style_cross , linewidth = 2,title = "HTF SuperTrend Losscut")


fill(mtp, tfl1p, color=color.new(Mlinecolor,70))
fill(tfl1p, tfl2p, color=color.new(Mlinecolor,80))
fill(tfl2p, tfl3p, color=color.new(Mlinecolor,90))


