OPEN-SOURCE SCRIPT

Responsive Moving Average with Trend Detection - MissouriTim

This indicator calculates a responsive moving average (RMA) that dynamically adjusts its sensitivity based on market volatility. This indicator is more responsive that SMAs, EMAs, WMAs, and HMAs. Here's how it functions:

Dynamic Length Adjustment: Utilizes the Average True Range (ATR) to adjust the length of the moving average. In times of increased volatility, the length decreases to make the average more responsive to price changes, and in quieter markets, it increases to reduce noise.

Responsive and Smoothed Moving Averages:
Responsive EMA: An initial Exponential Moving Average (EMA) is calculated with a dynamically adjusted length for responsiveness.
Smoothing: A secondary layer of smoothing is applied to this responsive EMA to further smooth out price fluctuations.

Trend Detection:
Detects trends by comparing the current smoothed EMA with its previous values:
Uptrend is identified when the current smoothed EMA is higher than the last two periods.
Downtrend is recognized when the current smoothed EMA is lower than the last two periods.
Consolidation occurs when neither an uptrend nor a downtrend is present.

Visual Representation:
The moving average line changes color:
Green for an uptrend.
Red for a downtrend.
Orange for consolidation.

Significant Trend Labels:
Labels are displayed when there's a significant change in the moving average:
Uptrend Labels appear when the EMA increases by more than the user-defined "Uptrend Label on % Change" threshold, placed at the high of the bar with green background.
Downtrend Labels are shown when the EMA decreases by more than the "Downtrend Label on % Change" threshold, positioned at the low of the bar with a red background.
Users can enable or disable these labels, and the thresholds for labeling uptrends and downtrends can be adjusted separately to match market conditions or user preferences.

This indicator is tailored for traders needing a moving average that adapts to market dynamics while providing clear visual feedback on significant trend changes via color-coded lines and labels.

Disclaimer