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.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.