The Parabolic SAR (Stop and Reverse, or SAR for short) is a widely used technical analysis tool among traders and analysts. It helps identify potential trend reversal points and provides guidance on when to enter or exit trades. Especially useful in trend-following strategies, mastering the mechanics and applications of SAR can enhance your ability to navigate complex market dynamics.
Because it is both simple and effective—particularly in trending markets—SAR is popular with both experienced professionals and beginners. Whether you’re a seasoned trader refining your strategy or a newcomer getting started, it’s worth taking the time to understand this indicator.
What Can the SAR Indicator Help You Do?
1. Identify Market Trends
The primary feature of the Parabolic SAR is its ability to detect the current trend direction. It appears as a series of dots (typically red) forming a parabola on a price chart.
- When the parabola is below the price, it suggests an uptrend.
- When the parabola is above the price, it indicates a downtrend.
2. Spot Potential Reversal Points
The SAR can also help identify potential trend reversals. By observing the switch of the SAR dots from below the price to above (or vice versa), traders can anticipate a change in trend. This can be used as a signal to either enter or exit a position.
How Is the SAR Calculated?
The SAR calculation consists of two key components: the Extreme Price (EP) and the Acceleration Factor (AF).
Extreme Price (EP)
The Extreme Price refers to the highest or lowest price recorded during the current trend:
- In an uptrend, EP is the highest price observed since the trend began.
- In a downtrend, EP is the lowest price observed since the trend began.
Acceleration Factor (AF)
The Acceleration Factor determines the sensitivity of the SAR. It starts at 0.02 and increases incrementally as new extreme prices are set. The maximum value is 0.20.
Adjustment rules:
- Initial value of AF = 0.02
- AF increases by 0.02 each time a new EP is reached
- AF caps at 0.20 and will not increase beyond that
This mechanism allows SAR to become more responsive as the trend strengthens, enabling it to better track price movements.
Parabolic SAR Calculation Formula
The SAR is calculated as follows:
SARnew = SARcurrent + AF × (EP–SARcurrent)
This formula ensures that the SAR value gradually moves closer to the price as the trend progresses, making it a dynamic indicator that adjusts to market conditions.
Trend Reversal
A trend reversal occurs when the price crosses the current SAR value. When this happens:
- The SAR is reset using the EP from the previous trend
- The AF is reset to its initial value (0.02)
- The trend direction switches
Code Example
import pandas as pd import matplotlib.pyplot as plt import allticks apple_stock_data = allticks.get_stock_data('AAPL') apple_stock_data = apple_stock_data.sort_index() def calculate_parabolic_sar(data, af_start=0.02, af_increment=0.02, af_max=0.20): sar = [0] * len(data) trend = 1 ep = data['Low'][0] af = af_start sar[0] = data['Low'][0] if trend == 1 else data['High'][0] for i in range(1, len(data)): prev_sar = sar[i - 1] if trend == 1: sar[i] = prev_sar + af * (ep - prev_sar) if data['Low'][i] < sar[i]: trend = -1 sar[i] = ep ep = data['High'][i] af = af_start else: if data['High'][i] > ep: ep = data['High'][i] af = min(af + af_increment, af_max) else: sar[i] = prev_sar - af * (prev_sar - ep) if data['High'][i] > sar[i]: trend = 1 sar[i] = ep ep = data['Low'][i] af = af_start else: if data['Low'][i] < ep: ep = data['Low'][i] af = min(af + af_increment, af_max) return sar apple_stock_data['SAR'] = calculate_parabolic_sar(apple_stock_data) plt.figure(figsize=(14, 7)) plt.plot(apple_stock_data['Close'], label='Apple Stock Price') plt.plot(apple_stock_data['SAR'], label='Parabolic SAR', linestyle='--') plt.title('Apple Stock Price with Parabolic SAR') plt.xlabel('Date') plt.ylabel('Price') plt.legend() plt.show()