OPEN-SOURCE SCRIPT
Timeframe fix Multi SMA Daily and Weekly

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.
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.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.