Indicator TutorialPine Script 6

Parabolic SAR: acceleration and reversals

Start sets the initial acceleration, Increment raises it after new extremes, and Maximum caps it.

The Parabolic SAR indicator plots a price reference that trails a directional move and switches sides when its reversal condition is met. Faster acceleration brings the reference closer to its extreme point, but does not establish a better trading signal. This guide explains the settings, the cost of repeated flips in a range, and why a plotted dot is different from an executed stop order.

Add Parabolic SAR to a TradingView chart

Open Indicators, search for Parabolic SAR, and select the built-in study. In Settings, check Start, Increment and Max Value. Keep the indicator on the chart timeframe when comparing it with the Pine example below.

SAR means Stop and Reverse. Dots below the price bars indicate the upward phase of the calculation; dots above indicate the downward phase. A phase can persist across many bars. It is not a measure of the probability that the next bar will rise or fall.

The TradingView SAR documentation describes the calculation and defaults. For other overlays, browse the TradingView indicators directory or compare Supertrend and its ATR-based bands.

Why Traders Use This Indicator

  • Track a changing price reference during a directional move.
  • Specify an observable side-change condition for alerts or a separate strategy.
  • Compare an exit-only rule with an always-reversing rule under the same execution assumptions.
ParameterDefaultDescription
Start0.02Initial acceleration factor at the start of a new SAR phase. Raising it increases the initial move toward the extreme point, holding other inputs constant.
Increment0.02Added to acceleration when an upward phase makes a new high or a downward phase makes a new low. It is not added automatically on every bar.
Maximum0.20Upper limit for acceleration. Once this is reached, further extremes update the extreme point without increasing acceleration. It is not a maximum loss or stop distance.
Calculation timeframeChart timeframe in this exampleChanging timeframe changes the high/low sequence and reversal timing. Match the symbol, session, timeframe and available history when comparing two plots.

How acceleration moves the SAR reference

The candidate update is previous SAR + previous AF × (previous EP - previous SAR). EP is the phase extreme: highest high while rising or lowest low while falling. Reversal tests and the two preceding bars' high/low constraints complete the calculation; this recurrence alone is not a full SAR implementation.

At a reversal, the previous phase extreme supplies the reset reference and acceleration restarts. Without reversal, the upward reference is constrained by the prior two lows, and the downward reference by the prior two highs. See TradingView's calculation and initialization rules. Use ta.sar() below rather than approximating those rules with a moving average.

A hypothetical step, before constraints

Assume prior SAR = 95 and prior EP = 105. With AF = 0.02, the candidate is 95 + 0.02 × 10 = 95.20. With AF = 0.10, it is 96.00. These are illustrative inputs, not market data. If the preceding lows constrain the candidate, the final plotted value differs.

With Start 0.02 and Increment 0.02, one subsequent new extreme raises AF to 0.04; another raises it to 0.06. A bar with no new extreme leaves AF unchanged. A lower Maximum only changes a phase once the uncapped acceleration would exceed it. Do not assume that changing the cap must alter every early dot.

Signal Interpretation

Persistent moves and repeated flips

Observed sequenceWhat the SAR rule doesWhat to inspect
Successive highs in an upward phaseUpdates the extreme and increases AF until capped.Whether ordinary pullbacks trigger exits before the intended holding period.
Alternating price moves in a rangeCan switch sides repeatedly and reset acceleration.Flip count, turnover, fees and the cost of entering the opposite direction.
Gap through a stop referenceRecalculates from the new bar's prices.The actual order type and available fill, not the appearance of the dot.

Hypothetical cost comparison: at $2 per execution, ten one-unit round trips cost $40 in commissions; two cost $8. Both exclude price gains/losses and slippage. A reversing order may combine closing and opening quantity, so apply the broker's actual fee schedule rather than equating one flip with one fixed fee.

A plotted dot is not a stop fill

The example is an indicator and submits no orders. An alert at a bar close, a market exit after that close, and a stop order resting during the bar are different rules. Specify when a stop level becomes known and when the order becomes active. Do not use a dot recalculated after a reversal as though it were an order already resting before the reversal.

TradingView's broker emulator documentation explains order timing and gap fills: a price-based order crossed in the gap can fill at the new bar's open rather than its requested price. Real execution also depends on liquidity and order handling. A stop reference does not cap realized loss.

Confirmation changes timing

Open-bar prices can change the current SAR output. The example allows its plot to update but waits for barstate.isconfirmed before marking or alerting on a side change. TradingView documents this flag as true on the closing update of a realtime bar. Waiting for the close trades earlier notification for a settled chart-bar condition; it does not certify future performance or prevent data revisions.

Combining with Other Indicators

An ADX threshold or moving-average direction rule can restrict which flips become entries. Such filters also reject some moves and delay others. Define the filter before comparing results; adding it is a test hypothesis, not proof of fewer losses.

For implementation, the Visual Pine Script Editor exposes SAR Start, Increment and Max Value. Use the Pine Script AI Coding Agent to draft custom confirmation and order rules. After creating a separate strategy with exposed inputs, the Strategy Optimizer can test parameter combinations. Keep commission and slippage assumptions fixed and record trade count alongside drawdown and net results. The indicator below cannot itself produce a strategy backtest.

Additional references: TradingView Parabolic SAR Strategy and standard versus synthetic chart backtests. Sources checked October 16, 2026.

Educational information only, not investment advice. No settings on this page have been established as profitable.

Writing Pine Script Manually

Challenges of Manual Coding

Handle the first available SAR value without treating initialization as a reversal.

Choose whether a signal uses an intrabar touch, a confirmed side change or an order that was already active.

Keep the pre-reversal stop reference separate from the dot plotted after the SAR resets.

Pine Script 6
//@version=6
indicator("Parabolic SAR: confirmed side changes", shorttitle="SAR flips", overlay=true)

start = input.float(0.02, "Start AF", minval=0.001, step=0.01)
increment = input.float(0.02, "AF increment", minval=0.001, step=0.01)
maximum = input.float(0.20, "AF maximum", minval=0.001, step=0.01)
showMarkers = input.bool(true, "Show confirmed flip markers")

if maximum < start
    runtime.error("AF maximum must be at least Start AF.")

sarValue = ta.sar(start, increment, maximum)
// Equality keeps the preceding side; this avoids treating a tie as a new flip.
var int side = 0
if not na(sarValue)
    side := sarValue < close ? 1 : sarValue > close ? -1 : nz(side[1], 0)

hasPreviousSide = not na(sarValue[1]) and nz(side[1], 0) != 0
flipUp = barstate.isconfirmed and hasPreviousSide and side == 1 and side[1] == -1
flipDown = barstate.isconfirmed and hasPreviousSide and side == -1 and side[1] == 1

plot(sarValue, "SAR reference (not an order)", color=side == 1 ? color.teal : color.orange, style=plot.style_cross, linewidth=2)
plotshape(showMarkers and flipUp, title="Confirmed upward flip", style=shape.triangleup, location=location.belowbar, color=color.teal, size=size.small, text="Up")
plotshape(showMarkers and flipDown, title="Confirmed downward flip", style=shape.triangledown, location=location.abovebar, color=color.orange, size=size.small, text="Down")

alertcondition(flipUp, "SAR upward flip at close", "SAR changed to the upward side at the chart bar close.")
alertcondition(flipDown, "SAR downward flip at close", "SAR changed to the downward side at the chart bar close.")

Maintenance Note: This Pine v6 indicator plots the built-in SAR and marks confirmed changes of its side relative to close. It ignores initialization and retains the previous side on an exact price tie. The current dot can move before close. Create alerts in TradingView using Once Per Bar Close, and recreate them after changing the script or inputs. No order placement, position sizing or multi-timeframe logic is included.

Build with Pineify Visual Editor

Pineify lets you configure supported indicators and export Pine Script. Available settings and plan requirements vary by indicator. Compare the generated rules with the example before using its signals.

FeatureManual Pine ScriptPineify Visual Editor
SAR calculationCall ta.sar() with Start, Increment and Maximum inputs.Select the existing SAR component and configure its Start, Increment and Max Value fields.
Plot inspectionPlot the series and compare closed bars with the built-in study.Review the generated SAR source and plot before adding custom conditions.
Custom flip behaviorWrite and check side, initialization and confirmation conditions.Build conditions from SAR output; inspect the exported logic against the intended confirmation rule.

Configure the supported SAR indicator without writing its calculation from scratch.

Inspect the generated Pine Script before extending it with strategy orders.

Step-by-Step Tutorial

1

Add Parabolic SAR

Open an overlay indicator project in the Visual Pine Script Editor and select the SAR component.

2

Set the three acceleration inputs

Use 0.02, 0.02 and 0.20 as a reproducible starting comparison, not as optimized settings.

3

Specify the signal rule

For custom code, tell the AI Coding Agent whether you want a closed-bar side change or a separate strategy with an active stop. Review the distinction in its output.

4

Export and compare

Compile in TradingView and compare the plot against the built-in SAR on the same closed bars. Test any strategy separately with costs.

Trading Strategies & Pro Tips

Exit-only versus stop-and-reverse

Hold the entry rule and position size fixed. Compare exiting on an opposite confirmed flip with exiting and entering the other direction. Record the different order counts and exposure between signals.

Pro Tip: TradingView also offers a separate built-in Parabolic SAR Strategy. Check its order rules and strategy properties separately from this close-confirmed indicator.

A small acceleration experiment

As an illustrative grid, hold Start at 0.02, compare Increment 0.01 versus 0.02, and Maximum 0.10 versus 0.20. Use one symbol, timeframe, entry rule and cost model for all four cases.

Pro Tip: Keep a later period untouched while choosing parameters. Compare trade count, net results after costs and drawdown there; the best in-sample setting is not a forecast.

A range-period stress test

Choose evaluation dates before viewing the parameter ranking. Inspect sequences of short losing trades, reversal quantities and sensitivity to higher assumed slippage.

Pro Tip: Use standard OHLC charts for execution testing. Synthetic chart prices can produce misleading simulated fills.

Common Mistakes to Avoid

  • Increasing AF on every bar instead of only when the phase makes a new extreme.
  • Treating the maximum acceleration factor as a maximum permitted loss.
  • Using a completed reversal dot as a stop price that was supposedly known earlier.
  • Comparing settings with different sessions, chart types or trading costs.
  • Calling a visually smoother series more profitable without a separate strategy test.

Frequently Asked Questions

It shows a price reference that switches between upward and downward phases. It can support a defined trailing or reversal rule, but does not measure trend strength, predict returns or place an order by itself.

They are the default Start, Increment and Maximum acceleration values. Start initializes acceleration, Increment raises it on new phase extremes, and Maximum caps it. They are not percentages of capital or a tested recommendation for your market.

This guide establishes no best settings. Compare a small grid with the same entry and exit rules, chart data, position size, commission and slippage. Check an untouched period and turnover as well as net results.

Price can repeatedly cross the reference without sustaining a directional move. Lower acceleration or an added filter changes those signals but can delay exits or reject later trends. Measure the tradeoff rather than assuming it removes losses.

The current output can change as open-bar prices update. This example waits for the chart bar close before producing flip markers or alert conditions. Its dots still update intrabar; data revisions and changed settings can alter recalculated history.

Not necessarily. A plotted dot creates no order, and a stop order does not guarantee a particular fill price. Specify when the order is submitted and account for gaps, slippage and fees. The post-reversal dot is not evidence of a fill at that level.

The indicator has no trade results to optimize. First create and verify a separate strategy with explicit entry, exit, sizing and execution rules. The Strategy Optimizer can then test exposed parameter combinations. Historical rankings do not establish future profitability.

Build a SAR rule you can inspect

  • Configure Start, Increment and Max Value in the Visual Pine Script Editor
  • Describe custom confirmation and order timing to the AI Coding Agent
  • Test a separate strategy before comparing parameter results

Disclaimer: Trading involves significant risk. The indicators, code, and strategies provided are for educational purposes only and do not constitute financial advice. Past performance is not indicative of future results.