BINANCE:ETHUSDT.P   Ethereum / TetherUS PERPETUAL CONTRACT
 //@version=5
indicator("Parabolic SAR", overlay=true)

// Parameter input untuk Parabolic SAR
input acceleration_factor = 0.02
input acceleration_limit = 0.2

// Inisialisasi variabel untuk Parabolic SAR
var float sar = na
var float af = acceleration_factor
var float ep = na
var float hp = na
var float lp = na
var int trend = 1

// Fungsi Parabolic SAR
sar_function() =>
if trend == 1
sar := sar + af * (ep - sar)
sar := max(sar, lp, hp)
if close < sar
trend := -1
sar := hp
ep := close
af := acceleration_factor
lp := low
else
sar := sar + af * (ep - sar)
sar := min(sar, lp, hp)
if close > sar
trend := 1
sar := lp
ep := close
af := acceleration_factor
hp := high

// Perhitungan Parabolic SAR
sar_function()

// Plot Parabolic SAR
plot(sar, color=trend == 1 ? color.green : color.red, style=plot.style_cross, linewidth=2)

// Update variabel Parabolic SAR
ep := if trend == 1 then max(ep, high) else min(ep, low)
hp := if trend == 1 then max(high, hp) else hp
lp := if trend == 1 then lp else min(low, lp)
af := if trend == 1 and ep == high then min(af + acceleration_factor, acceleration_limit) else af
af := if trend == -1 and ep == low then min(af + acceleration_factor, acceleration_limit) else af
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.