PROTECTED SOURCE SCRIPT
EMA Extension + Reversion Statistics

EMA Extension + Reversion Statistics
Description
This indicator is a statistical mean-reversion tool designed to quantify how far price has extended from its baseline trend (the Mean EMA) and calculate the historical probability of a reversion event.
Unlike standard oscillators that use arbitrary fixed numbers (like RSI > 70), this script uses a historical rolling window (default 10 years) of daily data to determine exactly what constitutes a "High" or "Extreme" deviation for the specific asset you are charting.
It answers two critical questions:
Is the price statistically overextended? (Are we in the top 2% of historical deviations?)
If I fade this move, what is the historical win rate? (e.g., "When price is this extended, it touches the 9 EMA within 5 days 82% of the time.")
Key Features
Dynamic Volatility Bands: Plots "High" (default 80th percentile) and "Extreme" (default 98th percentile) extension bands based on historical daily closes.
Real-Time Win Rates: An on-screen dashboard displays the historical success rate of three different mean-reversion strategies whenever price hits these bands.
Time-Independent Logic: The statistics are calculated on the Daily timeframe regardless of the chart you are viewing. This allows you to scalp on lower timeframes (like the 5m or 15m) while seeing the statistical pressure from the Daily chart.
Rolling Lookback: Uses an array-based memory system to calculate percentiles over a user-defined lookback period.
The 3 Reversion Strategies
The dashboard calculates the "Win Rate" for three specific scenarios. Note specifically which ones require a Close versus just a Touch:
Touch EMA (9):
Goal: Price must TOUCH the Target EMA (default 9 EMA) at any point during the day. Wicks count.
Constraint: Must happen within the defined "Max Days" (default 5).
Close Inside Band:
Goal: Price must CLOSE back inside the deviation band. A wick inside is not enough; the candle body must confirm the move.
Constraint: Must happen within the defined "Max Days" (default 2).
Touch Mean (20):
Goal: Price must TOUCH the Baseline Band EMA (default 20 EMA) at any point during the day.
Constraint: Must happen within the defined "Max Days" (default 10).
Fully Customizable Settings
This script is designed to be flexible for different trading styles, asset classes, and timeframes. You can adjust the statistical model to fit your specific needs by clicking the Settings (Gear Icon) on the indicator and navigating to the Inputs tab.
What You Can Customize:
Lookback Period (Years):
Default: 10 Years.
You can increase this for a more robust long-term model or decrease it for assets with less history (like newer crypto pairs).
Moving Averages (EMAs):
Change the Band EMA (Default: 20) if you prefer a slower baseline like the 50 EMA.
Change the Target EMA (Default: 9) if you scalp to a faster average like the 5 or 8 EMA.
Time Constraints (Max Days):
Define your own "Time Stop." If you believe a reversion trade isn't valid if it takes longer than 3 days, simply change the Max Days input from 5 to 3. The win rates will instantly update to reflect this stricter rule.
Dashboard Visibility:
Show Dashboard: Toggle the table on or off.
Table Position: Move the table to any corner of the chart (Top Right, Bottom Left, etc.) to fit your workspace.
Strategy Mode: Switch between viewing "Show All 3" strategies at once or focusing on a single strategy to keep your chart clean.
Visual Guide
Red Stepline: The "Extreme" deviation band. Historically, price rarely stays here long.
Orange Stepline: The "High" deviation band. Standard overbought/oversold zone.
Dashboard Colors:
Red Text: Stats relative to the Extreme Band.
Orange Text: Stats relative to the High Band.
Dashboard Data:
Dev: Shows the current deviation of price from the EMA in percent.
Columns: The percentages shown (e.g., "85%") represent the historical Win Rate of that strategy triggering from that specific band.
Disclaimer
This indicator is for educational and informational purposes only and does not constitute financial advice. The "Win Rates" displayed are based on historical data and do not guarantee future performance. Trading futures, options, and securities involves significant risk and is not suitable for every investor. You may lose more than your initial investment. Always trade with a risk management plan.
Description
This indicator is a statistical mean-reversion tool designed to quantify how far price has extended from its baseline trend (the Mean EMA) and calculate the historical probability of a reversion event.
Unlike standard oscillators that use arbitrary fixed numbers (like RSI > 70), this script uses a historical rolling window (default 10 years) of daily data to determine exactly what constitutes a "High" or "Extreme" deviation for the specific asset you are charting.
It answers two critical questions:
Is the price statistically overextended? (Are we in the top 2% of historical deviations?)
If I fade this move, what is the historical win rate? (e.g., "When price is this extended, it touches the 9 EMA within 5 days 82% of the time.")
Key Features
Dynamic Volatility Bands: Plots "High" (default 80th percentile) and "Extreme" (default 98th percentile) extension bands based on historical daily closes.
Real-Time Win Rates: An on-screen dashboard displays the historical success rate of three different mean-reversion strategies whenever price hits these bands.
Time-Independent Logic: The statistics are calculated on the Daily timeframe regardless of the chart you are viewing. This allows you to scalp on lower timeframes (like the 5m or 15m) while seeing the statistical pressure from the Daily chart.
Rolling Lookback: Uses an array-based memory system to calculate percentiles over a user-defined lookback period.
The 3 Reversion Strategies
The dashboard calculates the "Win Rate" for three specific scenarios. Note specifically which ones require a Close versus just a Touch:
Touch EMA (9):
Goal: Price must TOUCH the Target EMA (default 9 EMA) at any point during the day. Wicks count.
Constraint: Must happen within the defined "Max Days" (default 5).
Close Inside Band:
Goal: Price must CLOSE back inside the deviation band. A wick inside is not enough; the candle body must confirm the move.
Constraint: Must happen within the defined "Max Days" (default 2).
Touch Mean (20):
Goal: Price must TOUCH the Baseline Band EMA (default 20 EMA) at any point during the day.
Constraint: Must happen within the defined "Max Days" (default 10).
Fully Customizable Settings
This script is designed to be flexible for different trading styles, asset classes, and timeframes. You can adjust the statistical model to fit your specific needs by clicking the Settings (Gear Icon) on the indicator and navigating to the Inputs tab.
What You Can Customize:
Lookback Period (Years):
Default: 10 Years.
You can increase this for a more robust long-term model or decrease it for assets with less history (like newer crypto pairs).
Moving Averages (EMAs):
Change the Band EMA (Default: 20) if you prefer a slower baseline like the 50 EMA.
Change the Target EMA (Default: 9) if you scalp to a faster average like the 5 or 8 EMA.
Time Constraints (Max Days):
Define your own "Time Stop." If you believe a reversion trade isn't valid if it takes longer than 3 days, simply change the Max Days input from 5 to 3. The win rates will instantly update to reflect this stricter rule.
Dashboard Visibility:
Show Dashboard: Toggle the table on or off.
Table Position: Move the table to any corner of the chart (Top Right, Bottom Left, etc.) to fit your workspace.
Strategy Mode: Switch between viewing "Show All 3" strategies at once or focusing on a single strategy to keep your chart clean.
Visual Guide
Red Stepline: The "Extreme" deviation band. Historically, price rarely stays here long.
Orange Stepline: The "High" deviation band. Standard overbought/oversold zone.
Dashboard Colors:
Red Text: Stats relative to the Extreme Band.
Orange Text: Stats relative to the High Band.
Dashboard Data:
Dev: Shows the current deviation of price from the EMA in percent.
Columns: The percentages shown (e.g., "85%") represent the historical Win Rate of that strategy triggering from that specific band.
Disclaimer
This indicator is for educational and informational purposes only and does not constitute financial advice. The "Win Rates" displayed are based on historical data and do not guarantee future performance. Trading futures, options, and securities involves significant risk and is not suitable for every investor. You may lose more than your initial investment. Always trade with a risk management plan.
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用,没有任何限制 — 了解更多信息这里。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用,没有任何限制 — 了解更多信息这里。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。