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 open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.