strategy · on price · open source

Parabolic SAR strategy (0.02 / 0.02 / 0.2)

Parabolic SAR (0.02/0.02/0.2) long-only strategy: long while price closes above the SAR, flat below it. Rules, code and a costed backtest. Free to run. Deepwick Script runs a subset of Pine Script.

v1Updated 3 Oct 2026▲ 0 users
Running…
Loading chart…

What the Parabolic SAR strategy does

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.

Entry and exit rules

    Language reference: Deepwick Script.

    Default inputs

    InputDefaultMinMax
    Start0.020.010.1
    Increment0.020.010.1
    Maximum0.20.11
    Stop Loss %20.510
    Take Profit %6020

    How Deepwick fills this strategy

    • Market orders fill at the next bar's open.
    • Stops and limits follow the bar's path: open → nearer extreme → farther extreme → close.
    • Gaps fill at the open.
    • Commission is charged on every fill, and slippage applies to market and stop fills, as set in strategy().

    More on how backtests work

    Source code

    Deepwick Script, a subset of Pine Script · read-only

    //@version=6
    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)
    colorMid = input.color("color.orange", "Color  Mid")
    colorUp = input.color("color.green", "Color  Up")
    colorDown = input.color("color.red", "Color  Down")
    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=colorMid, style=plot.style_circles)
    plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=colorUp, text="L")
    plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=colorDown, text="X")
    alertcondition(longSignal, "SAR long entry", "Price closed above Parabolic SAR")
    alertcondition(exitSignal, "SAR exit", "Price closed below Parabolic SAR")
    

    Run it in Deepwick

    1. Open a chart of any crypto pair or CFD.
    2. Click “Scripts” and add this strategy.
    3. Press Run and read the trades in the Strategy Tester.
    Start free

    FAQ

    What are the standard Parabolic SAR settings?

    Start 0.02, increment 0.02, maximum 0.2, which is what the script uses. A lower increment makes the dots trail further from price and produces fewer flips.

    Does Parabolic SAR work in sideways markets?

    It tends to flip often in ranges, and each flip pays costs. Many traders add a trend filter such as ADX above a threshold; add it to the entry and compare.

    Why does it re-enter right after a stop?

    Entry is a state (close above SAR), not a flip. If the 2% stop or 6% target closes the trade while price is still above the SAR, it buys again on the next bar.

    Comments

    No comments yet.

    Sign in to comment.