OPEN-SOURCE SCRIPT
Mis à jour

MA Distance (% and ATR) + Threshold Count

1 067
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.
Notes de version
Updating Chart
Notes de version

  • Adding an option to show a background highlight when the price is within a defined normal range
  • Adding debug labels to show which MA thresholds are being hit


Clause de non-responsabilité

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