Strategy vault / Mean reversion
Parabolic SAR Divergence Trading Strategy
This strategy is a trading system based on divergence relationships between the Parabolic SAR indicator and price movement. By monitoring divergence phenomena between SAR indicator and price trends, it identifies…

Overview
This strategy is a trading system based on divergence relationships between the Parabolic SAR indicator and price movement. By monitoring divergence phenomena between SAR indicator and price trends, it identifies potential trend reversal points to capture market turning opportunities. The strategy employs the classic Parabolic SAR indicator as its core technical indicator, combined with divergence analysis methods to construct a complete trend-following trading system.
Strategy Principles
The core logic includes several key elements:
- Uses Parabolic SAR indicator to track price trends, featuring dynamic adjustment of acceleration factors
- Detects divergence between price and SAR indicator through a set lookback period
- Triggers long signals when bullish divergence occurs (price makes new lows while SAR doesn't)
- Triggers short signals when bearish divergence occurs (price makes new highs while SAR doesn't)
- Marks trading signals on charts using shape.triangleup and shape.triangledown
- Integrates alert functionality to notify traders of trading signals promptly
Strategy Advantages
- Scientific Indicator Selection
- Parabolic SAR is a market-tested mature indicator
- Indicator parameters can be flexibly adjusted for different market characteristics
- Reliable Signal Mechanism
- Divergence signals have strong trend prediction capability
- Combines price and indicator trends to reduce false signals
- Complete System Design
- Includes comprehensive signal generation, execution, and monitoring mechanisms
- Integrates graphical interface and alert functions for easy operation
Strategy Risks
- Parameter Sensitivity
- Improper SAR parameter settings may lead to overtrading
- Divergence detection period selection affects signal quality
- Market Adaptability
- May generate false signals in volatile markets
- Frequent invalid signals may occur in ranging markets
- Insufficient Risk Control
- Lacks stop-loss mechanism
- No position management system
Strategy Optimization Directions
- Enhanced Signal Filtering
- Add trend filters to trade only in main trend direction
- Incorporate volume indicators to verify signal validity
- Improved Risk Control
- Add dynamic stop-loss mechanism
- Design position management system
- Optimized Parameter Adjustment
- Develop adaptive parameter system
- Dynamically adjust parameters based on market conditions
Summary
This is a trend-following strategy based on classic technical indicators, capturing market turning points through divergence analysis. The strategy design is clear, implementation methods are concise, and it has good operability. However, in practical application, it still needs optimization according to specific market characteristics, especially in risk control aspects. Through adding filtering mechanisms and improving the risk control system, this strategy has the potential to achieve more stable trading performance.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-11 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("SAR Divergence Strategy", overlay=true)
// --- Inputs ---
length = input.int(14, title="SAR Length", minval=1)
accelerationFactor = input.float(0.02, title="Acceleration Factor", minval=0.01)
maximumFactor = input.float(0.2, title="Maximum Factor", minval=0.01)
// --- SAR Calculation ---
sar = ta.sar(length, accelerationFactor, maximumFactor)
// --- Divergence Detection ---
lookback = 5
// Bullish Divergence
bullCond = close[lookback] < close[lookback + 1] and sar[lookback] > sar[lookback + 1]
// Bearish Divergence
bearCond = close[lookback] > close[lookback + 1] and sar[lookback] < sar[lookback + 1]
// --- Strategy Logic ---
if (bullCond)
strategy.entry("Long", strategy.long)
if (bearCond)
strategy.entry("Short", strategy.short)
// --- Plotting ---
plot(sar, color=color.blue, linewidth=2, title="Parabolic SAR")
plotshape(bullCond, style=shape.triangleup, color=color.green, size=size.small, title="Bullish Divergence")
plotshape(bearCond, style=shape.triangledown, color=color.red, size=size.small, title="Bearish Divergence")
// --- Alerts ---
alertcondition(bullCond, title="Bullish SAR Divergence", message="Bullish Divergence detected")
alertcondition(bearCond, title="Bearish SAR Divergence", message="Bearish Divergence detected")Published by ChaoZhang on the FMZ strategy square · last modified 2024-11-12. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Parabolic-SAR-Divergence-Trading-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Dual Rail Parabolic SAR Bollinger Bands StrategyPine Script · Mean reversion
- Dynamic PSAR Stock Fluctuation Tracking StrategyPine Script · Mean reversion · 10m
- Parabolic SAR Trailing Stop Loss StrategyPine Script · Mean reversion · 3h
- Combining Simple Moving Average and Adaptive Moving Average StrategyPine Script · Mean reversion · 5m
- Multi Dimensional Technical Indicator Cross Confirmation Buy Signal Optimization StrategyPine Script · Mean reversion · 1d
- Multi Indicator Synergistic SAR Reversal Strategy with Filtered Entry ModelPine Script · Mean reversion · 3h