//@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
// bearish signal rule:
bearishRule = c2<o2 and c2<c2
// current trading State
ruleState = 0
ruleState := bullishRule ? 1 : bearishRule ? -1 : nz(ruleState)
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) and not na(new_trend)
if reversal_state == 0
if uptrend
EP := math.max(high, EP)
else
EP := math.min(low, EP)
if new_trend
AF := AF_initial
else
if EP != EP
AF := math.min(AF_maximum, AF + AF_increment)
else
AF := AF
SAR := SAR + AF * (EP - SAR)
if uptrend
SAR := math.min(SAR, low)
if not na(low)
SAR := math.min(SAR, low)
if SAR > low
uptrend := false
new_trend := true
SAR := math.max(high, EP)
EP := math.min(low, low)
reversal_state := 2
else
uptrend := true
new_trend := false
else
SAR := math.max(SAR, high)
if not na(high)
SAR := math.max(SAR, high)
if SAR < high
uptrend := true
new_trend := true
SAR := math.min(low, EP)
EP := math.max(high, high)
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")
Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.