OPEN-SOURCE SCRIPT
Aggiornato

Linear Mean Reversion Strategy

511
📘 Strategy Introduction: Linear Mean Reversion with Fixed Stop
This strategy implements a simple yet powerful mean reversion model that assumes price tends to oscillate around a dynamic average over time. It identifies statistically significant deviations from the moving average using a z-score, and enters trades expecting a return to the mean.

🧠 Core Logic:
A z-score is calculated by comparing the current price to its moving average, normalized by standard deviation, over a user-defined half-life window.

Trades are entered when the z-score crosses a threshold (e.g., ±1), signaling overbought or oversold conditions.

The strategy exits positions either when price reverts back near the mean (z-score close to 0), or if a fixed stop loss of 100 points is hit, whichever comes first.

⚙️ Key Features:
Dynamic mean and volatility estimation using moving average and standard deviation

Configurable z-score thresholds for entry and exit

Position size scaling based on z-score magnitude

Fixed stop loss to control risk and avoid prolonged drawdowns

🧪 Use Case:
Ideal for range-bound markets or assets that exhibit stationary behavior around a mean, this strategy is especially useful on assets with mean-reverting characteristics like currency pairs, ETFs, or large-cap stocks. It is best suited for traders looking for short-term reversions rather than long-term trends.
Note di rilascio
The idea is simple: if an instrument’s price is truly mean-reverting, we can expect it to return to its long-term average.

Most assets, however, behave more like random walks and show little tendency to revert. The VIX—an index of S&P 500 volatility—is a notable exception, exhibiting clear mean-reversion.

For this strategy, I’ve assumed a trading cost of 0.1%, which seems reasonable given the typical bid-ask spread on the VIX is about 0.18 points.

A z-score is calculated by comparing the current price to its moving average, normalized by standard deviation, over a user-defined half-life window.

Trades are entered when the z-score crosses a threshold (e.g., ±1), signaling overbought or oversold conditions.

The strategy exits positions either when price reverts back near the mean (z-score close to 0), or if a fixed stop loss is hit, whichever comes first.

Designed for a 1 H window, where the VIX’s mean reversion and assumed costs tend to align well.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.