OPEN-SOURCE SCRIPT
Parabolic SAR Extended (SAREXT)

- Extended Parabolic SAR with asymmetric acceleration factors for long/short positions.
- Parameterized by 8 parameters: start value, offset on reverse, and separate AF init/increment/max for long and short.
- Output range: sign-encoded — positive values indicate long (SAR below price), negative indicate short (SAR above price). Absolute value is the SAR level.
- Requires `2` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib `SarExt` reference implementation with ≥95% match rate.
## Introduction
SAREXT is the extended version of Wilder's Parabolic Stop And Reverse (1978). While standard PSAR uses symmetric acceleration factors (same AF parameters for both long and short positions), SAREXT allows independent AF configuration for each direction. This enables traders to apply tighter stops in one direction (e.g., faster acceleration when short to protect against bear market rallies) while using looser stops in the other. SAREXT also adds explicit start value control (force initial direction) and an offset applied on reversals.
The `startValue` parameter controls initial direction: positive forces long, negative forces short, zero auto-detects from directional movement (DM) comparison on bar 1 vs bar 0. The `offsetOnReverse` parameter shifts the SAR value on each reversal — adding a buffer to prevent immediate whipsaw.
## Historical Context
Wilder introduced the basic Parabolic SAR in *New Concepts in Technical Trading Systems* (1978). The extended version with asymmetric acceleration factors was popularized by the TA-Lib open-source library (2003+) as `TA_SAREXT`. The asymmetric AF concept addresses a known weakness of standard PSAR: bull and bear trends have different characteristics. Bull markets tend to climb gradually while bear markets fall sharply. Using the same AF parameters for both directions is suboptimal. SAREXT's asymmetric design allows practitioners to codify this market asymmetry.
## Parameter Mapping
| Parameter | Default | Effect |
|-----------|---------|--------|
| startValue | 0.0 | 0=auto-detect, >0=force long, <0=force short |
| offsetOnReverse | 0.0 | Buffer added to SAR on reversal. Reduces whipsaw. |
| afInitLong | 0.02 | Initial AF when entering long position |
| afLong | 0.02 | AF increment per new high in long mode |
| afMaxLong | 0.20 | Maximum AF in long mode |
| afInitShort | 0.02 | Initial AF when entering short position |
| afShort | 0.02 | AF increment per new low in short mode |
| afMaxShort | 0.20 | Maximum AF in short mode |
### Quality Metrics (1–10 Scale)
| Metric | Score | Rationale |
|--------|-------|-----------|
| Trend detection | 7 | Good in strong trends; whipsaws in ranges |
| Responsiveness | 9 | Asymmetric AF allows direction-tuned speed |
| False signals | 6 | offsetOnReverse can reduce whipsaw vs PSAR |
| Flexibility | 10 | 8 parameters cover symmetric and asymmetric use cases |
| Universality | 8 | Works on any timeframe and asset class |
## Common Pitfalls
1. **Asymmetric AF confusion**: The 8-parameter surface is large. Setting `afInitShort` very high (e.g., 0.10) makes short stops very tight, triggering rapid reversals back to long. Start with symmetric defaults and tune one side at a time.
2. **startValue vs auto-detect**: When `startValue != 0`, the initial SAR level is the absolute value of `startValue`, not derived from price data. If the chosen value is far from current price, the first few bars' SAR may be unrealistic.
3. **offsetOnReverse sign convention**: On long→short reversal, offset is *added* (moves SAR higher, further from price). On short→long reversal, offset is *subtracted* (moves SAR lower, further from price). Both increase the buffer between SAR and price at reversal points.
4. **Sign-encoded output**: Unlike PSAR which always outputs a positive SAR level, SAREXT encodes direction into the sign. Always use `Math.Abs(value)` for the actual SAR level, or use the `Sar` property directly.
6. **2-bar warmup**: SAREXT requires 2 bars (vs PSAR's 1 bar) because it needs two bars to compute directional movement for auto-detection.
## References
- Wilder, J. W. Jr. (1978). *New Concepts in Technical Trading Systems*. Trend Research. ISBN 978-0894590276.
- TA-Lib. "TA_SAREXT — SAR — Parabolic SAR — Extended."
- Kaufman, P. J. (2013). *Trading Systems and Methods*, 5th ed. Wiley.
- Parameterized by 8 parameters: start value, offset on reverse, and separate AF init/increment/max for long and short.
- Output range: sign-encoded — positive values indicate long (SAR below price), negative indicate short (SAR above price). Absolute value is the SAR level.
- Requires `2` bars of warmup before first valid output (IsHot = true).
- Validated against TA-Lib `SarExt` reference implementation with ≥95% match rate.
## Introduction
SAREXT is the extended version of Wilder's Parabolic Stop And Reverse (1978). While standard PSAR uses symmetric acceleration factors (same AF parameters for both long and short positions), SAREXT allows independent AF configuration for each direction. This enables traders to apply tighter stops in one direction (e.g., faster acceleration when short to protect against bear market rallies) while using looser stops in the other. SAREXT also adds explicit start value control (force initial direction) and an offset applied on reversals.
The `startValue` parameter controls initial direction: positive forces long, negative forces short, zero auto-detects from directional movement (DM) comparison on bar 1 vs bar 0. The `offsetOnReverse` parameter shifts the SAR value on each reversal — adding a buffer to prevent immediate whipsaw.
## Historical Context
Wilder introduced the basic Parabolic SAR in *New Concepts in Technical Trading Systems* (1978). The extended version with asymmetric acceleration factors was popularized by the TA-Lib open-source library (2003+) as `TA_SAREXT`. The asymmetric AF concept addresses a known weakness of standard PSAR: bull and bear trends have different characteristics. Bull markets tend to climb gradually while bear markets fall sharply. Using the same AF parameters for both directions is suboptimal. SAREXT's asymmetric design allows practitioners to codify this market asymmetry.
## Parameter Mapping
| Parameter | Default | Effect |
|-----------|---------|--------|
| startValue | 0.0 | 0=auto-detect, >0=force long, <0=force short |
| offsetOnReverse | 0.0 | Buffer added to SAR on reversal. Reduces whipsaw. |
| afInitLong | 0.02 | Initial AF when entering long position |
| afLong | 0.02 | AF increment per new high in long mode |
| afMaxLong | 0.20 | Maximum AF in long mode |
| afInitShort | 0.02 | Initial AF when entering short position |
| afShort | 0.02 | AF increment per new low in short mode |
| afMaxShort | 0.20 | Maximum AF in short mode |
### Quality Metrics (1–10 Scale)
| Metric | Score | Rationale |
|--------|-------|-----------|
| Trend detection | 7 | Good in strong trends; whipsaws in ranges |
| Responsiveness | 9 | Asymmetric AF allows direction-tuned speed |
| False signals | 6 | offsetOnReverse can reduce whipsaw vs PSAR |
| Flexibility | 10 | 8 parameters cover symmetric and asymmetric use cases |
| Universality | 8 | Works on any timeframe and asset class |
## Common Pitfalls
1. **Asymmetric AF confusion**: The 8-parameter surface is large. Setting `afInitShort` very high (e.g., 0.10) makes short stops very tight, triggering rapid reversals back to long. Start with symmetric defaults and tune one side at a time.
2. **startValue vs auto-detect**: When `startValue != 0`, the initial SAR level is the absolute value of `startValue`, not derived from price data. If the chosen value is far from current price, the first few bars' SAR may be unrealistic.
3. **offsetOnReverse sign convention**: On long→short reversal, offset is *added* (moves SAR higher, further from price). On short→long reversal, offset is *subtracted* (moves SAR lower, further from price). Both increase the buffer between SAR and price at reversal points.
4. **Sign-encoded output**: Unlike PSAR which always outputs a positive SAR level, SAREXT encodes direction into the sign. Always use `Math.Abs(value)` for the actual SAR level, or use the `Sar` property directly.
6. **2-bar warmup**: SAREXT requires 2 bars (vs PSAR's 1 bar) because it needs two bars to compute directional movement for auto-detection.
## References
- Wilder, J. W. Jr. (1978). *New Concepts in Technical Trading Systems*. Trend Research. ISBN 978-0894590276.
- TA-Lib. "TA_SAREXT — SAR — Parabolic SAR — Extended."
- Kaufman, P. J. (2013). *Trading Systems and Methods*, 5th ed. Wiley.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Rigorous technical indicators for Pine Script 6 with O(1) streaming, defensible math, and proper initialization. Fully documented, implemented in C#, transcribed to Pine Script, and wrapped for Python.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Rigorous technical indicators for Pine Script 6 with O(1) streaming, defensible math, and proper initialization. Fully documented, implemented in C#, transcribed to Pine Script, and wrapped for Python.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.