Master this powerful trend-following indicator in TradingView's Pine Script for dynamic stop-loss placement and trend reversal identification.
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.
The Parabolic SAR calculation involves several key elements:
//@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)
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.
The most direct application of Parabolic SAR is for trend identification and reversal signals. It's a stop-and-reverse system by design.
//@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)
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)
To get the most out of Parabolic SAR in Pine Script:
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.
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.
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