OPEN-SOURCE SCRIPT

Mean Reversion Pro

2 717
📊 Mean Reversion Pro — Data-Driven Edge on Any Market, Any Timeframe

Most mean reversion indicators tell you the price is "too far" from the moving average. This one tells you exactly how far is statistically worth trading — using your own chart's historical data as proof.

Works on all instruments and timeframes: futures (NQ, ES, CL, GC…), crypto (BTC, ETH, SOL…), forex (EUR/USD, GBP/USD…), indices (SPX, DAX, NASDAQ…), stocks, commodities — anything with a price and volume.

─────────────────────────────────────────
🔍 WHAT THIS INDICATOR DOES
─────────────────────────────────────────

Mean Reversion Pro silently analyses every historical instance where price deviated from a moving average by a given distance. For each of 15 tested threshold levels it computes:

• Win rate — % of times price returned to the MA within the timeout
• Expectancy — (win-rate × avg MFE) − (loss-rate × avg MAE)
• Profit Factor — gross gain / gross loss ratio
• Avg MAE — average adverse excursion (how far against you before reverting)
• Avg MFE — average favourable excursion (how far in your favour)
• Avg return time — average bars needed to reach the MA

It then automatically selects the threshold with the highest expectancy that also satisfies your minimum win-rate and minimum occurrences filters — and only then shows a signal. No manual optimisation. No curve-fitting.

─────────────────────────────────────────
⚙️ KEY FEATURES
─────────────────────────────────────────

✅ Universal — works on futures, crypto, forex, indices, stocks, commodities
✅ 3 threshold modes: fixed Points, ATR multiples, Z-Score (adapts to any volatility regime)
✅ 5 MA types: EMA, SMA, WMA, VWMA, Hull MA
✅ Auto-optimised threshold — the indicator finds the best level by itself
✅ Real-time dashboard: win-rate, expectancy, profit factor, MAE, MFE, return time (Long & Short)
✅ Dynamic bands: 1× and 1.5× optimal threshold zones drawn on the chart
✅ Non-repainting signals — only fires on confirmed, closed bars
✅ Optional filters: trend (EMA 50), volume, US session, minimum ATR
✅ Minimum history guard — signals are held until enough bars have been analysed
✅ All parameters fully exposed and documented with tooltips

─────────────────────────────────────────
📈 WHO IS THIS FOR
─────────────────────────────────────────

• Futures traders — NQ, MNQ, ES, MES, CL, GC, SI, ZB…
• Crypto traders — BTC, ETH, SOL and all altcoins on any exchange
• Forex traders — all major, minor and exotic pairs
• Index traders — SPX, NDX, DAX, FTSE, CAC, Nikkei…
• Stock traders and swing traders looking for mean reversion pullbacks
• Prop firm traders who need a systematic, rules-based edge
• Any trader tired of arbitrary support/resistance levels with no statistical backing

─────────────────────────────────────────
🧠 HOW TO USE IT
─────────────────────────────────────────

1. Apply to any chart on any timeframe
2. Let at least 500 bars load (recommended: 1000–2000 for robust statistics)
3. Choose Threshold Mode:
— Points → best for futures and indices (fixed price distances)
— ATR → best for crypto and forex (volatility-adjusted)
— Z-Score → best for statistical/quant approaches
4. Set your minimum Win Rate (default 65%) and minimum Occurrences (default 15)
5. A signal appears only when all statistical conditions are met AND your filters pass
6. Read the dashboard to assess setup quality before entering a trade

─────────────────────────────────────────
💡 WHY EXPECTANCY MATTERS MORE THAN WIN RATE
─────────────────────────────────────────

A strategy with 80% win rate can still lose money if the average loss is 5× the average win. Mean Reversion Pro uses expectancy — the only metric that combines win rate, average gain and average loss into a single number — as its selection criterion. A signal only appears when the math is in your favour.

─────────────────────────────────────────
⚠️ DISCLAIMER
─────────────────────────────────────────

This indicator is a decision-support tool only. It does not provide financial advice and does not guarantee future results. Past statistical performance is not indicative of future performance. Always use proper risk management.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.