OPEN-SOURCE SCRIPT
Native Timeframe Moving Average

📈 Native Timeframe Moving Average
Overview
Native Timeframe Moving Average allows you to plot a moving average that is always calculated from its own selected timeframe, regardless of the chart timeframe you're viewing.
Instead of recalculating the MA using the current chart bars, this indicator performs the entire moving-average calculation inside the selected source timeframe before mapping the result back onto your chart. This ensures the moving average always remains true to its native timeframe.
For example, selecting a 200 SMA on the Daily timeframe will always display the genuine 200-day SMA whether you're viewing a 15-minute, 1-hour, 4-hour, Daily, Weekly, or any other timeframe.
✨ Features
✔ Native timeframe moving averages
✔ SMA, EMA, WMA, RMA & VWMA
✔ Any TradingView timeframe
✔ Developing and Confirmed calculation modes
✔ Connected and Native display modes
✔ Standard MA Offset
✔ Uses TradingView Style settings for colour and line width
✔ No repainting or future leakage
✔ Lightweight and fast
⚙️ Value Modes
📡 Developing (Default)
Includes the active source-timeframe candle in the calculation.
This behaves like traders generally expect when viewing a higher-timeframe moving average on a lower-timeframe chart, allowing the MA to update as the source candle develops.
Perfect for discretionary chart analysis.
🔒 Confirmed
Uses only completed source-timeframe candles.
The plotted value remains unchanged until the next source-timeframe candle closes.
Ideal for:
• Strategies
• Alerts
• Stable signal generation
• Any workflow requiring confirmed higher-timeframe values
📉 Line Modes
🔗 Connected (Default)
Connects each source-timeframe moving-average value using straight lines.
This provides a cleaner, smoother appearance that most traders prefer when analysing trends across multiple timeframes.
Note: The connecting segments are visual interpolation between confirmed source-timeframe values. They improve readability but should not be interpreted as the exact value that existed on every individual chart bar.
🪜 Native
Displays the actual sampled moving-average value available on every chart bar.
When the selected timeframe is higher than the chart timeframe, the line naturally appears as a staircase because the source-timeframe value only updates when that timeframe produces a new value.
This mode is recommended whenever the output is being used for:
• Strategy logic
• Alerts
• Numerical comparisons
• Other indicators
💡 Typical Uses
• Overlay a Daily 200 SMA while trading the 15-minute chart
• View Weekly trend direction without changing chart timeframe
• Display Monthly moving averages on swing-trading charts
• Compare multiple native timeframe moving averages by adding multiple indicator instances
• Keep important higher-timeframe trend references visible while executing on lower timeframes
🎯 Why use this instead of a standard Moving Average?
A standard Moving Average is always calculated from the timeframe of the chart you're viewing.
This indicator keeps the calculation anchored to the timeframe you choose.
That means a 200 Daily SMA always remains a 200 Daily SMA, regardless of whether you're looking at a 5-minute chart or a Weekly chart. It never silently becomes a 200-bar moving average of the current chart timeframe.
🚀 Final Notes
This indicator was designed to provide a clean, reliable and flexible way to work with native timeframe moving averages across any chart.
Whether you're monitoring long-term trend structure while trading intraday or building multi-timeframe confluence into your analysis, Native Timeframe Moving Average keeps your moving averages true to their original timeframe while giving you the flexibility to choose between the smooth appearance of Connected mode and the mathematically exact representation of Native mode.
Overview
Native Timeframe Moving Average allows you to plot a moving average that is always calculated from its own selected timeframe, regardless of the chart timeframe you're viewing.
Instead of recalculating the MA using the current chart bars, this indicator performs the entire moving-average calculation inside the selected source timeframe before mapping the result back onto your chart. This ensures the moving average always remains true to its native timeframe.
For example, selecting a 200 SMA on the Daily timeframe will always display the genuine 200-day SMA whether you're viewing a 15-minute, 1-hour, 4-hour, Daily, Weekly, or any other timeframe.
✨ Features
✔ Native timeframe moving averages
✔ SMA, EMA, WMA, RMA & VWMA
✔ Any TradingView timeframe
✔ Developing and Confirmed calculation modes
✔ Connected and Native display modes
✔ Standard MA Offset
✔ Uses TradingView Style settings for colour and line width
✔ No repainting or future leakage
✔ Lightweight and fast
⚙️ Value Modes
📡 Developing (Default)
Includes the active source-timeframe candle in the calculation.
This behaves like traders generally expect when viewing a higher-timeframe moving average on a lower-timeframe chart, allowing the MA to update as the source candle develops.
Perfect for discretionary chart analysis.
🔒 Confirmed
Uses only completed source-timeframe candles.
The plotted value remains unchanged until the next source-timeframe candle closes.
Ideal for:
• Strategies
• Alerts
• Stable signal generation
• Any workflow requiring confirmed higher-timeframe values
📉 Line Modes
🔗 Connected (Default)
Connects each source-timeframe moving-average value using straight lines.
This provides a cleaner, smoother appearance that most traders prefer when analysing trends across multiple timeframes.
Note: The connecting segments are visual interpolation between confirmed source-timeframe values. They improve readability but should not be interpreted as the exact value that existed on every individual chart bar.
🪜 Native
Displays the actual sampled moving-average value available on every chart bar.
When the selected timeframe is higher than the chart timeframe, the line naturally appears as a staircase because the source-timeframe value only updates when that timeframe produces a new value.
This mode is recommended whenever the output is being used for:
• Strategy logic
• Alerts
• Numerical comparisons
• Other indicators
💡 Typical Uses
• Overlay a Daily 200 SMA while trading the 15-minute chart
• View Weekly trend direction without changing chart timeframe
• Display Monthly moving averages on swing-trading charts
• Compare multiple native timeframe moving averages by adding multiple indicator instances
• Keep important higher-timeframe trend references visible while executing on lower timeframes
🎯 Why use this instead of a standard Moving Average?
A standard Moving Average is always calculated from the timeframe of the chart you're viewing.
This indicator keeps the calculation anchored to the timeframe you choose.
That means a 200 Daily SMA always remains a 200 Daily SMA, regardless of whether you're looking at a 5-minute chart or a Weekly chart. It never silently becomes a 200-bar moving average of the current chart timeframe.
🚀 Final Notes
This indicator was designed to provide a clean, reliable and flexible way to work with native timeframe moving averages across any chart.
Whether you're monitoring long-term trend structure while trading intraday or building multi-timeframe confluence into your analysis, Native Timeframe Moving Average keeps your moving averages true to their original timeframe while giving you the flexibility to choose between the smooth appearance of Connected mode and the mathematically exact representation of Native mode.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.