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.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.