OPEN-SOURCE SCRIPT
Updated

MA Distance (% and ATR) + Threshold Count

635
MA Distance (% & ATR) + Threshold Count
This script visualizes how far price is extended from key moving averages using both percentage and ATR-based distance. It includes a dynamic threshold system that tracks how unusually extended price is, based on historical volatility.

🔍 Features:
Calculates distance from:

10 EMA, 20 SMA, 50 SMA, 100 SMA, 200 SMA

Measures both:

% distance from each MA

ATR-multiple distance from each MA

Automatically calculates dynamic upper/lower thresholds using a rolling standard deviation

Plots a colored dot when distance exceeds these thresholds

Dots appear above or below the bar depending on direction

Color-coded summary table displays:

% distance

ATR distance

Threshold extremes

Total number of threshold hits

🎯 Customization:
Toggle which MAs to display in the table

Set your own lookback window and threshold sensitivity (via stdev multiplier)

Show/hide dots based on how many thresholds are hit

Use this tool to identify when price is overextended from its moving averages and approaching historically significant levels of deviation. Great for spotting mean reversion setups, parabolic runs, or deep pullbacks.
Release Notes
Updating Chart

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.