Trend indicator
Parabolic SAR Calculator
Compute one step of the Parabolic SAR (Stop and Reverse) from the prior SAR, acceleration factor, and extreme point. The SAR tracks price like a trailing stop and flips when price crosses it.
Position is LONG — Trend continues
What the Parabolic SAR is
The Parabolic SAR (Stop and Reverse) was created by J. Welles Wilder and published in his 1978 book, New Concepts in Technical Trading Systems. It is a trend-following indicator that places a trailing stop below rising prices in an uptrend and above falling prices in a downtrend.
The SAR is calculated using an acceleration factor (AF) that starts at a minimum value, typically 0.02, and increases by a step amount each time the price records a new extreme point (highest high for long positions, lowest low for shorts), up to a maximum. This causes the SAR to accelerate toward price during strong trends, tightening the stop.
The indicator reverses when the price crosses the SAR, which is the signal to close the current position and enter in the opposite direction. This "stop and reverse" behavior is what gives the indicator its name.
How the SAR is calculated
The SAR calculation proceeds as follows. First, the new SAR equals the prior SAR plus the acceleration factor times the difference between the prior extreme point and the prior SAR. Then, if the current price crosses the SAR (price falls below it in a long position or rises above it in a short), a reversal occurs: the SAR becomes the prior extreme point, a new extreme is recorded from the current bar, and the AF resets to its minimum.
If no reversal occurs, the extreme point updates if a new high or low is recorded, and the AF increases by the step amount up to the maximum. This creates the characteristic behavior where the SAR accelerates in the direction of the trend until price violates the stop level.
What are TradingView and Pine Script?
TradingView is one of the most widely used charting and market-analysis platforms, where traders and analysts study price movement across stocks, crypto, forex, and futures on interactive charts. Pine Script is TradingView's own lightweight programming language, created so anyone can build custom tools that run directly on those charts.
People use Pine Script to build four main kinds of tools. Indicators calculate and plot values on the chart, exactly like the calculation above, but recomputed automatically on every bar. Strategies add explicit entry and exit rules and can be backtested against historical data in TradingView's Strategy Tester to see how they would have behaved. Screeners scan many symbols at once for conditions you define. Alerts notify you the moment a condition you specified occurs, so you do not have to watch the screen.
The value is precision and automation. Instead of eyeballing a chart, you describe exactly what you want measured, visualized, or notified about, and TradingView runs it consistently across any market and timeframe. That is why traders, analysts, and developers write Pine Script: it turns a manual charting idea into a repeatable tool. These tools are for tracking, visualizing, and testing market ideas; they do not tell you what to trade, and that decision always remains yours.
Writing that code by hand means learning Pine Script's syntax, its type system, and the exact names of hundreds of built-in functions. It is a real programming language, and small mistakes stop a script from compiling in the Pine Editor.
Turn this into Pine Script
Pine Script provides the Parabolic SAR with a single function call: ta.sar(start, increment, maximum). The three parameters control the initial acceleration factor, the increment per extreme, and the maximum value the AF can reach. These correspond directly to the inputs in this calculator.
The indicator is typically used by plotting the SAR as dots above or below price, then watching for the dot to flip to the other side, which signals a trend reversal. It works best in strong trending markets and can produce many whipsaws in ranging or choppy conditions.
//@version=6
indicator("Parabolic SAR", overlay=true)
start = input.float(0.02, "Start (AF Min)")
increment = input.float(0.02, "AF Increment")
maximum = input.float(0.2, "AF Maximum")
sar = ta.sar(start, increment, maximum)
plot(sar, "SAR", style=plot.style_cross, color=color.blue)PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.