Sarrrr

//version=5
indicator(title="SAR5", shorttitle="SAR5", overlay=true, timeframe="", timeframe_gaps=true)

// PARABOLIC SAR
start = input(defval=0.02, group="Parabolic SAR Settings")
increment = input(defval=0.02, group="Parabolic SAR Settings")
maximum = input(defval=0.2, title="Max Value", group="Parabolic SAR Settings")

// psarColor = input.color(#2962FF, title="PSAR Color", inline="PSAR1", group="Parabolic SAR Settings")
// psarWidth = input.int(1, minval=1, title="PSAR Width", inline="PSAR1", group="Parabolic SAR Settings")
// psarShape = input.string(defval=shape.cross, title="PSAR Shape", inline="PSAR1", group="Parabolic SAR Settings")

out = ta.sar(start, increment, maximum)
plot(out, "ParabolicSAR", style=plot.style_cross, color=#2962FF)
//plot(out, "ParabolicSAR", color=psarColor, linewidth=psarWidth)

// LINEAR SAR
//version=3
//study("LinearSAR", shorttitle="LinearSAR", overlay=true)
startLS = input.int(defval=2, minval=0, maxval=10, title="Start - Default = 2 - Multiplied by .01", group="Linear SAR Settings")
incrementLS = input.int(1, minval=0, maxval=10, title="Step Setting (Sensitivity) - Default = 2 - Multiplied by .01", group="Linear SAR Settings" )
maximumLS = input.int(1, minval=1, maxval=10, title="Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10", group="Linear SAR Settings")
susLS = input(true, "Show Up Trending Parabolic Sar", group="Linear SAR Settings")
sdsLS = input(true, "Show Down Trending Parabolic Sar", group="Linear SAR Settings")
discLS = input(false, title="Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2", group="Linear SAR Settings")

startCalc = startLS * .01
incrementCalc = incrementLS * .01
maximumCalc = maximumLS * .10

sarUp = ta.sar(startCalc, incrementCalc, maximumCalc)
sarDown = ta.sar(startCalc, incrementCalc, maximumCalc)

colUp = close >= sarDown ? color.lime : na
colDown = close <= sarUp ? color.red : na

plot(susLS and sarUp ? sarUp : na, title="Linear SAR - Up Trending SAR", style=plot.style_circles, linewidth=2,color=colUp)
plot(sdsLS and sarDown ? sarDown : na, title="Linear SAR - Down Trending SAR", style=plot.style_circles, linewidth=2,color=colDown)

showZones = input(true, title="Show Bullish/Bearish Zones")
lenc=input(50)
o2=ta.linreg( open, lenc,0 )
h2 = ta.linreg( high, lenc,0 )
l2 = ta.linreg( low, lenc,0 )
c2=ta.linreg( close, lenc,0 )
// bullish signal rule:
bullishRule = c2>o2 and c2>c2[1]
// bearish signal rule:
bearishRule = c2<o2 and c2<c2[1]
// current trading State
ruleState = 0
ruleState := bullishRule ? 1 : bearishRule ? -1 : nz(ruleState[1])
bullishBearColor = showZones ? ( ruleState==1 ? color.new(color.green, 90) : ruleState==-1 ? color.new(color.red, 90) : color.new(color.gray, 90) ) : na
bgcolor(color = bullishBearColor , title="Linear SAR - Bullish/Bearish Zones")


// LUCID SAR
AF_initial = input(defval=0.02, group="LUCID SAR SETTINGS")
AF_increment = input(defval=0.02, group="LUCID SAR SETTINGS")
AF_maximum = input(defval=0.2, group="LUCID SAR SETTINGS")

LUCID_SAR(initial, increment, maximum) =>

// start with uptrend
uptrend = true
new_trend = false
EP = high
SAR = low
AF = AF_initial

// before a reversal, the reversal_state is 0;
// after a reversal, within the same candle as the reversal,
// the reversal_state can be 1 (uptrend) or 2 (downtrend)
reversal_state = 0

if not na(uptrend[1]) and not na(new_trend[1])
if reversal_state == 0
if uptrend[1]
EP := math.max(high, EP[1])
else
EP := math.min(low, EP[1])
if new_trend[1]
AF := AF_initial
else
if EP != EP[1]
AF := math.min(AF_maximum, AF[1] + AF_increment)
else
AF := AF[1]
SAR := SAR[1] + AF * (EP - SAR[1])
if uptrend[1]
SAR := math.min(SAR, low[1])
if not na(low[2])
SAR := math.min(SAR, low[2])
if SAR > low
uptrend := false
new_trend := true
SAR := math.max(high, EP[1])
EP := math.min(low, low[1])
reversal_state := 2
else
uptrend := true
new_trend := false
else
SAR := math.max(SAR, high[1])
if not na(high[2])
SAR := math.max(SAR, high[2])
if SAR < high
uptrend := true
new_trend := true
SAR := math.min(low, EP[1])
EP := math.max(high, high[1])
reversal_state := 1
else
uptrend := false
new_trend := false
else
if reversal_state == 1
EP := high
if low < SAR
SAR := EP
EP := low
reversal_state == 2
uptrend := false
else
EP := low
if high > SAR
SAR := EP
EP := high
reversal_state == 1
uptrend := true
SAR

L_SAR = LUCID_SAR(AF_initial, AF_increment, AF_maximum)

plot(L_SAR, color = color.blue, style = plot.style_cross, linewidth = 2, title="LUCID SAR - Çizim")

// TRIPLE SAR
roSarSlow = ta.sar(0.01,0.01,0.2)
roSarModerate = ta.sar(0.01,0.02,0.2)
roSarFast = ta.sar(0.01,0.03,0.2)

plot(roSarSlow, style=plot.style_cross, color=color.blue, linewidth=2, title="TRIPLE SAR - Slow")
plot(roSarModerate, style=plot.style_cross, color=color.green, linewidth=2, title="TRIPLE SAR - Moderate")
plot(roSarFast, style=plot.style_cross, color=color.red,linewidth=2, title="TRIPLE SAR - Fast")

//SAR AVG
sarOrt = (sarUp + out + L_SAR) / 3
plot(sarOrt, style=plot.style_cross, color=color.green, linewidth=2, title="SAR5 - Ortalama")
Trend Analysis

כתב ויתור