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.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。