strategy · on price · open source

Parabolic SAR Strategy

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

Classic Parabolic SAR trend-following: long when price closes above the SAR dots (dots below price), flip to flat when SAR crosses above.

  • Lower Increment for tighter, faster stops; raise Max for stronger trends.
  • SAR dots are plotted on the chart for visual confirmation.
  • Combine with an ADX filter to avoid choppy reversals.

Source code

//@version=5
strategy("Parabolic SAR Strategy", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05)
start = input.float(0.02, "Start", minval=0.01, maxval=0.1, step=0.01)
inc = input.float(0.02, "Increment", minval=0.01, maxval=0.1, step=0.01)
max = input.float(0.2, "Maximum", minval=0.1, maxval=1, step=0.05)
stopPct = input.float(2, "Stop Loss %", minval=0.5, maxval=10, step=0.1)
tpPct = input.float(6, "Take Profit %", minval=0, maxval=20, step=0.1)
sar = ta.sar(start, inc, max)
longSignal = strategy.position_size == 0 and close > sar
exitSignal = strategy.position_size > 0 and close < sar
if longSignal
    strategy.entry("Long", strategy.long)
if strategy.position_size > 0
    strategy.exit("Risk", stop=stopPct > 0 ? strategy.position_avg_price * (1 - stopPct / 100) : na, limit=tpPct > 0 ? strategy.position_avg_price * (1 + tpPct / 100) : na)
if exitSignal
    strategy.close("Long", comment="SAR flip")
p_SAR = plot(sar, "SAR", color=color.orange, style=plot.style_circles)
plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=color.green, text="L")
plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=color.red, text="X")
alertcondition(longSignal, "SAR long entry", "Price closed above Parabolic SAR")
alertcondition(exitSignal, "SAR exit", "Price closed below Parabolic SAR")

Comments

No comments yet.

Sign in to comment.