OPEN-SOURCE SCRIPT
Mis à jour

MA Slope Indicator

48
a complete Pine Script (version 5) indicator for TradingView that implements what you're describing. It calculates Simple Moving Averages (SMAs) for four lengths (10, 20, 200, and 400 bars by default—these are configurable via inputs). For each SMA, it computes a "slope" value by comparing the current SMA value to the average of the previous X SMA values (where X is also a configurable input, defaulting to 5 bars).

The slope is calculated as: current_SMA - avg_of_previous_X_SMAs.
A positive slope indicates an upward trend (e.g., the MA is rising relative to its recent history).
A negative slope indicates a downward trend.
Zero means flat.
The script plots:
The four SMAs as lines on the chart (for reference).
Four histograms below the chart showing the slope values for each SMA, colored green for positive, red for negative, and gray for zero/flat.
This uses only simple moving averages (ta.sma() in Pine Script).
Notes de version
Simple Moving Averages (SMAs) for four lengths (10, 20, 200, and 400 bars by default—these are configurable via inputs). For each SMA, it computes a "slope" value by comparing the current SMA value to the average of the previous X SMA values (where X is also a configurable input, defaulting to 5 bars).

The slope is calculated as: current_SMA - avg_of_previous_X_SMAs.
A positive slope indicates an upward trend (e.g., the MA is rising relative to its recent history).
A negative slope indicates a downward trend.
Zero means flat.
The script plots:
The four SMAs as lines on the chart (for reference).
Four histograms below the chart showing the slope values for each SMA, colored green for positive, red for negative, and gray for zero/flat.
This uses only simple moving averages (ta.sma() in Pine Script).

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.