OPEN-SOURCE SCRIPT
NIL - Dynamic Timeframe EMA

NIL - Dynamic Timeframe EMA (Limited)
This indicator automatically plots higher-timeframe EMAs (1H, 1D, 1W, 1M) on any chart timeframe while keeping your chart clean and professional.
It intelligently calculates the correct EMA length based on the current bar duration and automatically hides any EMA that matches or is lower than the chart's timeframe (no more redundant or flat lines).
Perfect for intraday traders who want to see daily, weekly, and monthly EMA context without manual adjustments.
═
█ OVERVIEW
The script converts standard time-based EMAs into dynamic periods:
• 1-hour EMA
• 1-day EMA
• 1-week EMA
• 1-month EMA
It uses approximate trading minutes (390 min per day, 21 trading days per month) for accurate calculations across all timeframes — from seconds to monthly charts.
Key Smart Feature:
The indicator automatically hides EMAs that are no longer meaningful:
• On 1H or higher → 1H EMA is hidden
• On Daily or higher → 1H + 1D EMAs are hidden
• On Weekly or higher → 1H + 1D + 1W EMAs are hidden
• On Monthly → only 1M EMA remains (if enabled)
This prevents visual clutter and keeps the chart focused.
═
█ FEATURES
═
█ HOW TO USE
1. Add the indicator to any chart
2. Enable/disable each EMA via the inputs
3. Adjust colors as desired
4. (Optional) Increase "Max EMA Lookback" if working on very low timeframes
The top-right table will always show you:
• Which EMAs are active
• The exact period used for each
• Whether the period was capped
Best Use Cases:
• Intraday trading with higher-timeframe context
• Swing trading on lower timeframes
• Quickly assessing trend alignment across multiple time horizons
═
█ INPUTS
Display
• Show 1H EMA, Show 1D EMA, Show 1W EMA, Show 1M EMA
Colors
• Individual color selection for each EMA line
Limits
• Max EMA Lookback — protects against Pine Script calculation limits (default 5000)
═
█ NOTES & LIMITATIONS
• Calculations are performed on the chart's native data (not using request.security() — faster, no repainting).
• Uses standard trading session approximations (390 minutes/day).
• Very high periods on extremely low timeframes (e.g. 1-second) are automatically capped.
Enjoy cleaner charts with meaningful higher-timeframe EMAs!
Feel free to leave feedback or suggestions for future improvements.
This indicator automatically plots higher-timeframe EMAs (1H, 1D, 1W, 1M) on any chart timeframe while keeping your chart clean and professional.
It intelligently calculates the correct EMA length based on the current bar duration and automatically hides any EMA that matches or is lower than the chart's timeframe (no more redundant or flat lines).
Perfect for intraday traders who want to see daily, weekly, and monthly EMA context without manual adjustments.
═
█ OVERVIEW
The script converts standard time-based EMAs into dynamic periods:
• 1-hour EMA
• 1-day EMA
• 1-week EMA
• 1-month EMA
It uses approximate trading minutes (390 min per day, 21 trading days per month) for accurate calculations across all timeframes — from seconds to monthly charts.
Key Smart Feature:
The indicator automatically hides EMAs that are no longer meaningful:
• On 1H or higher → 1H EMA is hidden
• On Daily or higher → 1H + 1D EMAs are hidden
• On Weekly or higher → 1H + 1D + 1W EMAs are hidden
• On Monthly → only 1M EMA remains (if enabled)
This prevents visual clutter and keeps the chart focused.
═
█ FEATURES
- Fully automatic period calculation based on current timeframe
- Smart show/hide logic — no redundant lines
- Dynamic info table showing actual periods used
- Capping system to respect Pine Script's 5000-bar limit (configurable)
- Clean, customizable colors and display options
- Works on all timeframes (seconds, minutes, daily, weekly, monthly)
═
█ HOW TO USE
1. Add the indicator to any chart
2. Enable/disable each EMA via the inputs
3. Adjust colors as desired
4. (Optional) Increase "Max EMA Lookback" if working on very low timeframes
The top-right table will always show you:
• Which EMAs are active
• The exact period used for each
• Whether the period was capped
Best Use Cases:
• Intraday trading with higher-timeframe context
• Swing trading on lower timeframes
• Quickly assessing trend alignment across multiple time horizons
═
█ INPUTS
Display
• Show 1H EMA, Show 1D EMA, Show 1W EMA, Show 1M EMA
Colors
• Individual color selection for each EMA line
Limits
• Max EMA Lookback — protects against Pine Script calculation limits (default 5000)
═
█ NOTES & LIMITATIONS
• Calculations are performed on the chart's native data (not using request.security() — faster, no repainting).
• Uses standard trading session approximations (390 minutes/day).
• Very high periods on extremely low timeframes (e.g. 1-second) are automatically capped.
Enjoy cleaner charts with meaningful higher-timeframe EMAs!
Feel free to leave feedback or suggestions for future improvements.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.