OPEN-SOURCE SCRIPT
MA Slots - Multi-Timeframe

MA Slots - Multi-Timeframe
A moving average toolkit built around one idea: instead of separate, duplicated MA settings for each chart timeframe, you configure a flat pool of MA "slots" once, and each slot decides for itself which timeframes it appears on.
How it works
- 20 native slots. Each has its own Period, Type (SMA/EMA/RMA/VWMA/WMA), Source, Color, and Width — plus four checkboxes: Intraday / Daily / Weekly / Monthly. Check one box and that slot shows only while your chart is on that timeframe class, computed directly from your chart's own bars — a normal, smoothly-updating line, nothing fetched from elsewhere. Check two or more boxes (e.g. Daily and Weekly) and the same MA definition covers both — you don't need to re-enter the same period/type twice to reuse it across timeframes; the boxes just say where else that one definition applies. Only one box is ever "live" at a time, since a chart can only be one timeframe class at once.
- 5 cross-timeframe overlay slots, for the specific case of wanting a different timeframe's MA visible on your current chart — e.g. a Weekly MA overlaid on a Daily chart. These are separate from the 20 native slots because they work differently under the hood (see Limitations below).
- 4 timeframe-scoped cloud fills — one each for Intraday/Daily/Weekly/Monthly. Each shades the area between two of your 20 native slots (pick which two by number), colored by which one is above the other. Because the picker is scoped to a single timeframe class, and because the script validates your choice against that class's own checkboxes, a mismatched pick (e.g. picking a slot that isn't enabled for the timeframe you're viewing) shows a clear on-chart warning instead of silently doing nothing.
How to use it
Set up a slot's Period/Type/Source once, then tick whichever timeframe(s) you want it visible on. With 20 slots × several settings each, expect a long settings panel — it's organized into one numbered group per slot so you can navigate it without scanning a flat list.
Why it's original
This isn't a per-timeframe-group design (a fixed number of MAs hardcoded to each of four separate sections) the way most multi-timeframe MA scripts are built. It's a flat, shared-definition model where one MA can serve multiple timeframes at once without duplicate configuration, with a separate, clearly-labeled mechanism for the genuinely different cross-timeframe-overlay case, and built-in validation feedback for the cloud feature rather than a silent failure mode.
Limitations
- The 5 overlay slots use request.security() to pull a different timeframe's data onto your current chart. Because that source timeframe updates less often than your chart, the line will hold flat and then step to a new value — this is expected, not a bug. It also means historical bars can show that timeframe's completed value earlier than a live chart would have (a well-known repainting trade-off of this technique) — worth knowing if you use it for precise historical analysis.
- The 20 native slots avoid this entirely: they only ever show data native to the chart you're currently viewing, so there's no repainting risk there.
- A slot with no timeframe boxes checked simply won't appear anywhere until you check at least one — that's intentional (all 20 slots aren't meant to be active by default).
Open-source, MPL 2.0 licensed.
A moving average toolkit built around one idea: instead of separate, duplicated MA settings for each chart timeframe, you configure a flat pool of MA "slots" once, and each slot decides for itself which timeframes it appears on.
How it works
- 20 native slots. Each has its own Period, Type (SMA/EMA/RMA/VWMA/WMA), Source, Color, and Width — plus four checkboxes: Intraday / Daily / Weekly / Monthly. Check one box and that slot shows only while your chart is on that timeframe class, computed directly from your chart's own bars — a normal, smoothly-updating line, nothing fetched from elsewhere. Check two or more boxes (e.g. Daily and Weekly) and the same MA definition covers both — you don't need to re-enter the same period/type twice to reuse it across timeframes; the boxes just say where else that one definition applies. Only one box is ever "live" at a time, since a chart can only be one timeframe class at once.
- 5 cross-timeframe overlay slots, for the specific case of wanting a different timeframe's MA visible on your current chart — e.g. a Weekly MA overlaid on a Daily chart. These are separate from the 20 native slots because they work differently under the hood (see Limitations below).
- 4 timeframe-scoped cloud fills — one each for Intraday/Daily/Weekly/Monthly. Each shades the area between two of your 20 native slots (pick which two by number), colored by which one is above the other. Because the picker is scoped to a single timeframe class, and because the script validates your choice against that class's own checkboxes, a mismatched pick (e.g. picking a slot that isn't enabled for the timeframe you're viewing) shows a clear on-chart warning instead of silently doing nothing.
How to use it
Set up a slot's Period/Type/Source once, then tick whichever timeframe(s) you want it visible on. With 20 slots × several settings each, expect a long settings panel — it's organized into one numbered group per slot so you can navigate it without scanning a flat list.
Why it's original
This isn't a per-timeframe-group design (a fixed number of MAs hardcoded to each of four separate sections) the way most multi-timeframe MA scripts are built. It's a flat, shared-definition model where one MA can serve multiple timeframes at once without duplicate configuration, with a separate, clearly-labeled mechanism for the genuinely different cross-timeframe-overlay case, and built-in validation feedback for the cloud feature rather than a silent failure mode.
Limitations
- The 5 overlay slots use request.security() to pull a different timeframe's data onto your current chart. Because that source timeframe updates less often than your chart, the line will hold flat and then step to a new value — this is expected, not a bug. It also means historical bars can show that timeframe's completed value earlier than a live chart would have (a well-known repainting trade-off of this technique) — worth knowing if you use it for precise historical analysis.
- The 20 native slots avoid this entirely: they only ever show data native to the chart you're currently viewing, so there's no repainting risk there.
- A slot with no timeframe boxes checked simply won't appear anywhere until you check at least one — that's intentional (all 20 slots aren't meant to be active by default).
Open-source, MPL 2.0 licensed.
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.