SAR MTF levels
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mildSnail31034

//@version=4
study("SAR MTF levels", overlay=true)

showsar = input(title="Show Parabolic SAR", type=input.bool, defval=true)
start = input(title="SAR Start", type=input.float, step=0.001,defval=0.02)
increment = input(title="SAR increment", type=input.float, step=0.001,defval=0.02)
maxsar = input(title="SAR max", type=input.float, step=0.01, defval=0.2)
lbloff = input(title="Labels offset(bars)", type=input.integer,defval=3,minval=0)
psar = sar(start,increment, maxsar)
sar1 = security(syminfo.tickerid,"1",psar)
sar5 = security(syminfo.tickerid,"5",psar)
sar15 = security(syminfo.tickerid,"15",psar)
sar60 = security(syminfo.tickerid,"60",psar)
sar4hr = security(syminfo.tickerid,"240",psar)
sarD = security(syminfo.tickerid,"D",psar)
sarW = security(syminfo.tickerid,"W",psar)
sarM = security(syminfo.tickerid,"M",psar)
bullcolor = input(title="Bull color",type=input.color,defval=color.green)
bearcolor = input(title="Bear color",type=input.color,defval=color.red)

sar1lvl = input(title="Show 1m level",type=input.bool,defval=true)
sar1line = input(title="Show 1m line",type=input.bool,defval=false)
sar1color = sar1[0]>close ? bearcolor:bullcolor
plot(sar1lvl and sar1line ? sar1:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar1color)
plotshape(sar1lvl?sar1:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="1m",color=sar1color)

sar5lvl = input(title="Show 5m level",type=input.bool,defval=true)
sar5line = input(title="Show 5m line",type=input.bool,defval=false)
sar5color = sar5[0]>close ? bearcolor:bullcolor
plot(sar5lvl and sar5line ? sar5:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar5color)
plotshape(sar5lvl?sar5:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="5m",color=sar5color)

sar15lvl = input(title="Show 15m level",type=input.bool,defval=true)
sar15line = input(title="Show 15m line",type=input.bool,defval=false)
sar15color = sar15[0]>close ? bearcolor:bullcolor
plot(sar15lvl and sar15line ? sar15:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar15color)
plotshape(sar15lvl?sar15:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="15m",color=sar15color)

sar60lvl = input(title="Show 1hr level",type=input.bool,defval=true)
sar60line = input(title="Show 1hr line",type=input.bool,defval=false)
sar60color = sar60[0]>close ? bearcolor:bullcolor
plot(sar60lvl and sar60line ? sar60:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar60color)
plotshape(sar60lvl?sar60:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="1hr",color=sar60color)

sar4hrlvl = input(title="Show 4hrs level",type=input.bool,defval=true)
sar4hrline = input(title="Show 4hrs line",type=input.bool,defval=false)
sar4hrcolor = sar4hr[0]>close ? bearcolor:bullcolor
plot(sar4hrlvl and sar4hrline ? sar4hr:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sar4hrcolor)
plotshape(sar4hrlvl?sar4hr:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="4h",color=sar4hrcolor)


sarDlvl = input(title="Show daily level",type=input.bool,defval=true)
sarDline = input(title="Show daily line",type=input.bool,defval=false)
sarDcolor = sarD[0]>close ? bearcolor:bullcolor
plot(sarDlvl and sarDline ? sarD:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sarDcolor)
plotshape(sarDlvl?sarD:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="D",color=sarDcolor)

sarWlvl = input(title="Show weekly level",type=input.bool,defval=true)
sarWline = input(title="Show weekly line",type=input.bool,defval=false)
sarWcolor = sarW[0]>close ? bearcolor:bullcolor
plot(sarWlvl and sarWline ? sarW:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sarWcolor)
plotshape(sarWlvl?sarW:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="W",color=sarWcolor)

sarMlvl = input(title="Show monthly level",type=input.bool,defval=true)
sarMline = input(title="Show monthly line",type=input.bool,defval=false)
sarMcolor = sarM[0]>close ? bearcolor:bullcolor
plot(sarMlvl and sarMline ? sarM:na,show_last=1,offset=3,linewidth=2,trackprice=true,color=sarMcolor)
plotshape(sarMlvl?sarM:na,style=shape.cross ,location=location.absolute,offset=lbloff,show_last=1,text="M",color=sarMcolor)





















