Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-parabolic-sar

$ Pine Script Parabolic SAR (Stop and Reverse)

Master this powerful trend-following indicator in TradingView's Pine Script for dynamic stop-loss placement and trend reversal identification.

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

What is Parabolic SAR?

The Parabolic Stop and Reverse (SAR) indicator, developed by J. Welles Wilder Jr., is a time and price based trading tool used to determine the direction of an asset's momentum and the point at which to place a stop-loss or take profit. It's often visualized as a series of dots, either above or below the price bars, indicating the current trend direction.

A primary strength of the Parabolic SAR is its ability to adapt to accelerating trends. As a trend develops, the SAR dots accelerate towards the price, tightening the stop-loss level and locking in more profits. When the trend reverses, the dots "stop and reverse" to the other side of the price, signaling a potential new trend.

02

Components and Calculation

The Parabolic SAR calculation involves several key elements:

  • Start (Initial) Acceleration Factor (AF): Typically 0.02.
  • Increment: The amount by which the AF increases with each new high/low (e.g., 0.02).
  • Maximum Acceleration Factor (Max AF): The upper limit for the AF (e.g., 0.20).
  • Extreme Point (EP): The highest high during an uptrend or the lowest low during a downtrend.
03

Basic Parabolic SAR Implementation in Pine Script

pine-script@terminal
//@version=5
indicator("My Parabolic SAR Indicator", overlay=true)

// Inputs for Parabolic SAR parameters
start = input.float(0.02, title="Start AF")
increment = input.float(0.02, title="Increment")
maximum = input.float(0.20, title="Maximum AF")

// Calculate Parabolic SAR using the built-in function
sarValue = ta.sar(start, increment, maximum)

// Plot the Parabolic SAR dots
plot(sarValue, "SAR", style=plot.style_circles, linewidth=2, color=sarValue < close ? color.green : color.red)
$ ✓ Compiled successfully
04

Key Interpretation

Key Interpretation

When the dots are below the price bars, it signals an uptrend. When the dots are above the price bars, it signals a downtrend. A dot switching sides indicates a trend reversal.

05

Practical Parabolic SAR Strategies

1. Trend Following and Reversal Signals

The most direct application of Parabolic SAR is for trend identification and reversal signals. It's a stop-and-reverse system by design.

  • Buy Signal: When the SAR dots flip from being above the price to below the price.
  • Sell Signal: When the SAR dots flip from being below the price to above the price.
//@version=5
strategy("Parabolic SAR Trend Strategy", overlay=true)

start = input.float(0.02, title="Start AF")
increment = input.float(0.02, title="Increment")
maximum = input.float(0.20, title="Maximum AF")

sarValue = ta.sar(start, increment, maximum)

longCondition = ta.crossover(close, sarValue)
shortCondition = ta.crossunder(close, sarValue)

if (longCondition)
    strategy.entry("Long", strategy.long)
    
if (shortCondition)
    strategy.entry("Short", strategy.short)

plot(sarValue, "SAR", style=plot.style_circles, linewidth=2, color=sarValue < close ? color.green : color.red)

2. Parabolic SAR as a Dynamic Stop-Loss / Trailing Stop

Parabolic SAR is an excellent tool for placing dynamic stop-loss orders. As the trend progresses, the SAR dots move closer to the price, effectively trailing the market.

//@version=5
strategy("Parabolic SAR Dynamic Stop-Loss", overlay=true)

start = input.float(0.02, title="Start AF")
increment = input.float(0.02, title="Increment")
maximum = input.float(0.20, title="Maximum AF")

sarValue = ta.sar(start, increment, maximum)

fastMA = ta.ema(close, 20)
slowMA = ta.ema(close, 50)
longEntry = ta.crossover(fastMA, slowMA)
shortEntry = ta.crossunder(fastMA, slowMA)

if (longEntry)
    strategy.entry("Buy", strategy.long)
    strategy.exit("Long Exit", from_entry="Buy", stop=sarValue)

if (shortEntry)
    strategy.entry("Sell", strategy.short)
    strategy.exit("Short Exit", from_entry="Sell", stop=sarValue)

plot(sarValue, "SAR", style=plot.style_circles, linewidth=2, color=sarValue < close ? color.green : color.red)
06

Optimizing Parabolic SAR Performance

To get the most out of Parabolic SAR in Pine Script:

  • Parameter Tuning: Adjust `start`, `increment`, and `maximum` AF values. A smaller increment results in a smoother SAR that's further from price, while a larger increment makes it more sensitive and closer to price.
  • Combine with Other Indicators: Parabolic SAR is best used as a trend-confirming or stop-loss tool. Combine it with trend strength indicators (like ADX) or oscillators (like RSI) to filter false signals.
  • Multi-Timeframe Analysis: Confirm SAR signals on a higher timeframe before acting on signals from a lower timeframe.
  • Filter Ranging Markets: Avoid using Parabolic SAR alone in choppy or sideways markets, as it can generate frequent false signals (whipsaws).
07

Caution

Caution

Parabolic SAR is a trend-following indicator. It performs poorly in sideways or range-bound markets, where it can generate frequent false signals. Always use it with a trend filter.

08

Common Parabolic SAR Pitfalls

  • Whipsaws: In non-trending or highly volatile, non-directional markets, SAR can produce many premature stop-and-reverse signals.
  • Lagging: While it accelerates towards price, it is still a lagging indicator. Signals may sometimes come after a significant portion of the move has already occurred.
  • Not a standalone entry signal: It's more effective as a trailing stop or exit signal rather than a primary entry signal, especially without confluence from other indicators.
09

Conclusion

Conclusion

The Parabolic SAR is a unique and effective indicator in Pine Script for identifying trends and managing trades with dynamic stop-loss levels. Its ability to accelerate towards price makes it excellent for capturing profits in strong trends. By understanding its calculation and combining it judiciously with other indicators and market analysis, you can leverage Parabolic SAR to enhance your trading strategies and improve your trade management.

Enhance Your Trading

Get a high-performance Pine Script analysis tool for actionable market insights, designed for traders on the move.

This strategy runs in live mode on TradingView, helping you identify potential opportunities.

Get Pine Script Strategy