OPEN-SOURCE SCRIPT

MA Slots - Multi-Timeframe

508
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.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.