OPEN-SOURCE SCRIPT
Daily 5-SMA (intraday)

Daily 5-SMA Equivalent
This indicator translates a daily Simple Moving Average into its mathematically equivalent period for any intraday (or higher) timeframe, so the line you see on a 5-minute chart represents the same lookback window as the daily SMA on a daily chart — no manual period recalculation needed.
How it works
The script measures how many bars of the current timeframe fit inside the total minute-span of the reference SMA. For example, a 5-day SMA covers 1,950 minutes on a stock market (5 × 390 min/day). On a 5-minute chart that becomes a 390-period SMA; on a 15-minute chart it becomes a 130-period SMA. The conversion is automatic whenever you change timeframes.
An information table in the top-right corner always shows the active timeframe, the calculated equivalent period, the reference setting, and the selected market type — so you can verify the math at a glance.
Inputs
Source — Price field used for the calculation (default: close).
Reference Days — The number of daily bars the SMA spans. Default is 5 (the classic daily 5-SMA). Accepts 1–50.
Market Type — Determines how many minutes constitute a trading day:
24h — 1,440 min/day, for Forex and Crypto markets.
Stock — 390 min/day (6.5-hour session), for equities and equity futures.
Timeframe support
The period conversion handles seconds, minutes, hours, days, weeks, and monthly timeframes. On daily or higher timeframes the indicator still plots correctly, though it is most useful on intraday charts.
Alerts
Four alert conditions are included:
Price crosses above the SMA equivalent
Price crosses below the SMA equivalent
SMA is rising
SMA is falling
Usage notes
Set Market Type to Stock for equities and NQ/ES/MES futures. Use 24h for Bitcoin, Ethereum, Forex pairs, or any continuously traded instrument. The displayed equivalent period will always be at least 1, regardless of how high a timeframe you are viewing.
This indicator translates a daily Simple Moving Average into its mathematically equivalent period for any intraday (or higher) timeframe, so the line you see on a 5-minute chart represents the same lookback window as the daily SMA on a daily chart — no manual period recalculation needed.
How it works
The script measures how many bars of the current timeframe fit inside the total minute-span of the reference SMA. For example, a 5-day SMA covers 1,950 minutes on a stock market (5 × 390 min/day). On a 5-minute chart that becomes a 390-period SMA; on a 15-minute chart it becomes a 130-period SMA. The conversion is automatic whenever you change timeframes.
An information table in the top-right corner always shows the active timeframe, the calculated equivalent period, the reference setting, and the selected market type — so you can verify the math at a glance.
Inputs
Source — Price field used for the calculation (default: close).
Reference Days — The number of daily bars the SMA spans. Default is 5 (the classic daily 5-SMA). Accepts 1–50.
Market Type — Determines how many minutes constitute a trading day:
24h — 1,440 min/day, for Forex and Crypto markets.
Stock — 390 min/day (6.5-hour session), for equities and equity futures.
Timeframe support
The period conversion handles seconds, minutes, hours, days, weeks, and monthly timeframes. On daily or higher timeframes the indicator still plots correctly, though it is most useful on intraday charts.
Alerts
Four alert conditions are included:
Price crosses above the SMA equivalent
Price crosses below the SMA equivalent
SMA is rising
SMA is falling
Usage notes
Set Market Type to Stock for equities and NQ/ES/MES futures. Use 24h for Bitcoin, Ethereum, Forex pairs, or any continuously traded instrument. The displayed equivalent period will always be at least 1, regardless of how high a timeframe you are viewing.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.