OPEN-SOURCE SCRIPT
TimeSMA

This is a GREAT SCRIPT. You can now easily view a daily moving average on ANY timeframe, - daily, 2h, 30m, 45sec, etc.
The Problem with a Standard SMA
A 20 SMA on a daily chart averages the last 20 trading days. Switch to a 30m chart and that same "20 SMA" now covers only 10 hours. It's no longer a 20-day SMA — it's just 20 candles of whatever timeframe you're on.
The Fix
Enable Time-Based mode and set Length to 20. Now it's a true 20-day SMA on every timeframe — daily, 2h, 30m, or 5m. The script automatically calculates how many bars are needed to represent exactly 20 trading days.
Features
The Problem with a Standard SMA
A 20 SMA on a daily chart averages the last 20 trading days. Switch to a 30m chart and that same "20 SMA" now covers only 10 hours. It's no longer a 20-day SMA — it's just 20 candles of whatever timeframe you're on.
The Fix
Enable Time-Based mode and set Length to 20. Now it's a true 20-day SMA on every timeframe — daily, 2h, 30m, or 5m. The script automatically calculates how many bars are needed to represent exactly 20 trading days.
Features
- Time-Based mode toggle — works as a standard SMA when disabled
- Vertical line marking the oldest bar included in the calculation
- Bull/bear background shading
- Edge case warnings for monthly timeframes
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。