OPEN-SOURCE SCRIPT
MA Stack (Multi-Timeframe Moving Averages)

WHAT IT DOES
MA Stack replaces the usual clutter of adding moving averages to a chart one by one. It plots up to five moving averages in a single indicator. Each moving average can have its own type, length, timeframe, offset and color.
The script adds three optional visual layers:
• Fills between adjacent moving averages. The area is green when the faster MA is above the slower MA and orange when it is below. This makes compression, expansion and crossovers of the MA stack easier to recognize.
• Trend background, disabled by default. The background is green when the fastest MA is above every slower MA, red when it is below all of them, and yellow when the stack has a mixed order.
• Slope projections. Each moving average is extended into the future with a dotted line based on its latest one-bar slope. The projection always uses the same color as its moving average. It is a visual extrapolation, not a price forecast or trading signal.
HOW IT WORKS
Each of the five MA slots calculates one moving average using the selected source, type and length. The available types are SMA, EMA, WMA, VWMA, HMA and RMA.
Each slot can use the chart timeframe or a separate higher timeframe. Higher-timeframe calculations use confirmed values with lookahead disabled. In real time, the script uses the previous confirmed higher-timeframe value, so the higher-timeframe lines update after confirmation rather than following an unfinished higher-timeframe bar.
The slope projection takes the latest one-bar change in the moving average and extends that change over the selected projection length, which is 10 bars by default. The script maintains one projection line per moving average and updates it in place, preventing old projection lines from accumulating on the chart.
PRESETS
The presets provide commonly used moving-average combinations:
• Classic 20/50/200 SMA — short-, medium- and long-term simple moving averages.
• EMA Ribbon 8/13/21/34/55 — a Fibonacci-spaced EMA ribbon for observing compression, expansion and changes in trend structure.
• Golden Cross 50/200 SMA — the traditional pair used to identify golden-cross and death-cross conditions. The fill changes color when the averages cross.
• Scalping 9/21 EMA — a fast EMA pair intended for observing short-term momentum.
• Swing 10/20/50 EMA — three exponential moving averages for observing multi-day trend structure.
• Multi-TF Trend (21/50 EMA, D+W) — the 21 and 50 EMA from the Daily timeframe together with the 21 and 50 EMA from the Weekly timeframe. This preset makes it possible to compare price with both higher-timeframe structures on one chart.
• Bitcoin Support Band (20W SMA / 21W EMA) — the 20-week SMA and 21-week EMA, calculated from Weekly data regardless of the chart timeframe.
Select Manual to configure all five MA slots individually. Manual settings include enable or disable, MA type, length, timeframe, offset and color. Colors, offsets, line width and visual controls remain available when a preset is selected.
SETTINGS
• Preset and Source — select a preset and the price source used in all calculations.
• MA 1 to MA 5 — configure each slot's status, type, length, timeframe, offset and color. An empty timeframe uses the chart timeframe. These calculation settings are used when Preset is set to Manual; colors and offsets remain available for presets.
• Visuals — enable or disable fills, the trend background and slope projections; set the projection length and line width. The trend background is disabled by default.
HOW TO USE IT
Use a preset when you want a familiar MA combination without configuring every line manually. Use Manual mode when you need different MA types, periods or timeframes.
The relative order of the moving averages can help organize trend context:
• A faster MA above the slower averages indicates bullish alignment.
• A faster MA below the slower averages indicates bearish alignment.
• A mixed or compressed stack indicates that trend direction is less clearly aligned.
These observations are descriptive, not entry or exit signals. They should be combined with the user's own market analysis and risk management.
LIMITATIONS
• The slope projection is a straight-line extrapolation of the latest change in an MA. It does not predict future prices.
• Higher-timeframe values update only after confirmation. This creates a deliberate delay compared with an unfinished higher-timeframe bar.
• A slot's selected timeframe should normally be equal to or higher than the chart timeframe. For example, a Weekly moving average is not intended for use as a lower-timeframe data source on a Monthly chart.
• Moving averages are lagging calculations derived from past prices. Presets do not guarantee that a particular combination is suitable for every market or timeframe.
MA Stack is an open-source visual organization tool built from standard moving-average calculations. It does not generate automated trade signals or alerts and does not constitute investment advice.
MA Stack replaces the usual clutter of adding moving averages to a chart one by one. It plots up to five moving averages in a single indicator. Each moving average can have its own type, length, timeframe, offset and color.
The script adds three optional visual layers:
• Fills between adjacent moving averages. The area is green when the faster MA is above the slower MA and orange when it is below. This makes compression, expansion and crossovers of the MA stack easier to recognize.
• Trend background, disabled by default. The background is green when the fastest MA is above every slower MA, red when it is below all of them, and yellow when the stack has a mixed order.
• Slope projections. Each moving average is extended into the future with a dotted line based on its latest one-bar slope. The projection always uses the same color as its moving average. It is a visual extrapolation, not a price forecast or trading signal.
HOW IT WORKS
Each of the five MA slots calculates one moving average using the selected source, type and length. The available types are SMA, EMA, WMA, VWMA, HMA and RMA.
Each slot can use the chart timeframe or a separate higher timeframe. Higher-timeframe calculations use confirmed values with lookahead disabled. In real time, the script uses the previous confirmed higher-timeframe value, so the higher-timeframe lines update after confirmation rather than following an unfinished higher-timeframe bar.
The slope projection takes the latest one-bar change in the moving average and extends that change over the selected projection length, which is 10 bars by default. The script maintains one projection line per moving average and updates it in place, preventing old projection lines from accumulating on the chart.
PRESETS
The presets provide commonly used moving-average combinations:
• Classic 20/50/200 SMA — short-, medium- and long-term simple moving averages.
• EMA Ribbon 8/13/21/34/55 — a Fibonacci-spaced EMA ribbon for observing compression, expansion and changes in trend structure.
• Golden Cross 50/200 SMA — the traditional pair used to identify golden-cross and death-cross conditions. The fill changes color when the averages cross.
• Scalping 9/21 EMA — a fast EMA pair intended for observing short-term momentum.
• Swing 10/20/50 EMA — three exponential moving averages for observing multi-day trend structure.
• Multi-TF Trend (21/50 EMA, D+W) — the 21 and 50 EMA from the Daily timeframe together with the 21 and 50 EMA from the Weekly timeframe. This preset makes it possible to compare price with both higher-timeframe structures on one chart.
• Bitcoin Support Band (20W SMA / 21W EMA) — the 20-week SMA and 21-week EMA, calculated from Weekly data regardless of the chart timeframe.
Select Manual to configure all five MA slots individually. Manual settings include enable or disable, MA type, length, timeframe, offset and color. Colors, offsets, line width and visual controls remain available when a preset is selected.
SETTINGS
• Preset and Source — select a preset and the price source used in all calculations.
• MA 1 to MA 5 — configure each slot's status, type, length, timeframe, offset and color. An empty timeframe uses the chart timeframe. These calculation settings are used when Preset is set to Manual; colors and offsets remain available for presets.
• Visuals — enable or disable fills, the trend background and slope projections; set the projection length and line width. The trend background is disabled by default.
HOW TO USE IT
Use a preset when you want a familiar MA combination without configuring every line manually. Use Manual mode when you need different MA types, periods or timeframes.
The relative order of the moving averages can help organize trend context:
• A faster MA above the slower averages indicates bullish alignment.
• A faster MA below the slower averages indicates bearish alignment.
• A mixed or compressed stack indicates that trend direction is less clearly aligned.
These observations are descriptive, not entry or exit signals. They should be combined with the user's own market analysis and risk management.
LIMITATIONS
• The slope projection is a straight-line extrapolation of the latest change in an MA. It does not predict future prices.
• Higher-timeframe values update only after confirmation. This creates a deliberate delay compared with an unfinished higher-timeframe bar.
• A slot's selected timeframe should normally be equal to or higher than the chart timeframe. For example, a Weekly moving average is not intended for use as a lower-timeframe data source on a Monthly chart.
• Moving averages are lagging calculations derived from past prices. Presets do not guarantee that a particular combination is suitable for every market or timeframe.
MA Stack is an open-source visual organization tool built from standard moving-average calculations. It does not generate automated trade signals or alerts and does not constitute investment advice.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.