OPEN-SOURCE SCRIPT

Timeframe fix Multi SMA Daily and Weekly

235
How it works

All moving averages are calculated from the symbol’s closing price using the standard Simple Moving Average formula. The important design choice is that the moving averages are fixed to their intended higher timeframes:

* The 13D, 20D, 50D, and 200D SMAs are always calculated from daily candles.
* The 50W, 100W, and 200W SMAs are always calculated from weekly candles.

This means the values do not change into “chart-timeframe SMAs” when the user switches to an intraday, hourly, 4-hour, or other lower timeframe chart. For example, the 200D SMA remains the 200-day SMA even when viewed on a 15-minute chart, and the 50W SMA remains the 50-week SMA even when viewed on a daily or intraday chart.

The script uses TradingView’s higher-timeframe data requests to project these fixed daily and weekly SMA levels onto the active chart. This allows traders to analyze lower-timeframe price action while still seeing the same higher-timeframe reference levels they would see on the daily or weekly chart.

For the plotted lines, the script uses higher-timeframe values with gaps enabled, so the displayed levels behave visually like native higher-timeframe data on lower timeframes. For the last-bar labels, the script retrieves the latest available daily or weekly SMA value without gaps, so the labels remain visible and readable at the current price scale.

Lookahead is disabled, so the script does not intentionally use future higher-timeframe data.

Clause de non-responsabilité

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