# Rainbow MA Stack

A Trend concept (Moving-average lineage) in the LuxAlgo Library, with 1 indicator implementation.

## What is a Rainbow MA Stack?

A rainbow MA stack plots many moving averages at once, colored in a gradient so the group reads as a single band. Two constructions share the name: a set of averages with stepped lengths, for example ten [SMAs](https://www.luxalgo.com/library/concept/sma/) from short to long, and Mel Widner's original 1997 Rainbow Charts, where a short average is smoothed again and again so each line is a two-period smoothing of the previous line. Either way, the information is in the band's geometry, not in any single line.

Widner introduced Rainbow Charts in the July 1997 issue of Technical Analysis of Stocks & Commodities, together with a companion rainbow oscillator scoring where price sits within the band and how wide it is. His construction starts from a two-period simple average of price and smooths it nine more times, so the inner lines hug price while the outer ones carry progressively longer effective lag. The name has since attached to any family of stepped-length averages, [EMAs](https://www.luxalgo.com/library/concept/ema/) and [VWMAs](https://www.luxalgo.com/library/concept/vwma/) included, with Fibonacci-spaced length sets a popular variant.

The standard read: lines stacked in length order and fanning apart mark an established trend with agreement across horizons; lines compressing and braiding mark consolidation; price cutting into the band warns that the shortest horizons have already flipped. The logic is the same as an [MA ribbon](https://www.luxalgo.com/library/concept/ma-ribbon/), and the two terms overlap heavily in practice, with rainbow usually implying more lines and a gradient palette.

One glance answers three questions single-average tools answer piecemeal: direction (the gradient's tilt), agreement (whether the lines are in length order), and conviction (how wide the fan is). The same information could be assembled from separate [moving average crossovers](https://www.luxalgo.com/library/concept/moving-average-crossovers/) and slope checks, but the stack shows it as texture. The cost is redundancy and lag: every line is computed from the same closes, so the stack can look unanimous because it is one signal drawn ten times, and the long end answers slowly.

## How to identify a rainbow stack's regime on a chart

The read is geometric: line order, band width, and price's position relative to the band.

1. Plot the stack, Widner's ten recursive smoothings or a set of stepped-length averages, colored in a gradient from shortest to longest.
2. Check ordering: shortest lines nearest price with the rest in sequence below (uptrend) or above (downtrend) marks an aligned regime.
3. Judge width: a fanning band shows horizons agreeing; a knotted band shows consolidation.
4. Track price against the band: riding its upper edge, holding within it, or slicing through the full stack are three different messages.
5. Watch the short end first; inner lines curling against the gradient are the earliest visible sign the alignment is ending.

## How it's calculated

Ten recursively smoothed moving averages plotted as a fan; their ordering and spacing describe trend direction and strength.

```
MA_1,t = SMA_2(P)_t = (P_t + P_t-1) / 2
MA_k,t = SMA_2(MA_(k-1))_t = (MA_(k-1),t + MA_(k-1),t-1) / 2, for k = 2 to 10
Bullish stack: MA_1,t > MA_2,t > ... > MA_10,t
Bearish stack: MA_1,t < MA_2,t < ... < MA_10,t
Spread_t = max(MA_1,t, ..., MA_10,t) - min(MA_1,t, ..., MA_10,t)

  P_t: source price at bar t, usually the close
  SMA_2: two-bar simple moving average
  MA_k,t: k-th rainbow line at bar t
  k: recursion depth, 1 to 10
  Spread_t: distance between the highest and lowest rainbow lines at bar t
  t: current bar
```

The recursive SMA_2 construction is Mel Widner's Rainbow Charts (1997).

A common variant plots ordinary SMAs or EMAs of stepped lengths instead (for example 10 through 100) and reads the same ordering logic.

A widening spread indicates a strengthening trend; a compressed, interleaved fan indicates consolidation.

## How traders use it

- As a visual regime gauge: fan width stands in for trend strength, compression for range conditions, and color-ordered stacking for alignment across lookbacks.
- As layered [dynamic support and resistance](https://www.luxalgo.com/library/concept/dynamic-s-r-via-ma/): pullbacks that hold in the upper bands of a rising rainbow keep the trend read intact, while a decisive close through the whole stack is a common reversal warning.
- As a compression-breakout setup: when the entire stack knots together, the first sustained expansion out of the knot is followed directionally, similar in spirit to Guppy GMMA compression plays; a [breakout](https://www.luxalgo.com/library/concept/breakout/) through the stack's far side often anchors the entry.
- As a regime input for systems: line order and fan width quantify neatly (count of correctly ordered pairs, band width as a share of price), feeding a [trend regime label](https://www.luxalgo.com/library/concept/trend-regime-label/) or an [MA slope filter](https://www.luxalgo.com/library/concept/ma-slope-filter/).
- In an established rainbow trend, traders stalk pullback entries in the band's middle depths; a push to its far edge more often means the trend itself is failing.

## Rainbow stacks vs other moving-average constructs

- **MA Ribbon** (https://www.luxalgo.com/library/concept/ma-ribbon/): Mostly naming: ribbon usually means a handful of stepped-length averages, rainbow a larger gradient-colored set, with Widner's original build recursive rather than length-stepped. The reading conventions are identical.
- **MA Envelope** (https://www.luxalgo.com/library/concept/ma-envelope/): An envelope is one average shifted up and down by a fixed offset, so its width is a parameter. A rainbow's width is emergent, set by how much the underlying horizons disagree, exactly the information a fixed offset discards.
- **Supertrend** (https://www.luxalgo.com/library/concept/supertrend/): Supertrend collapses trend state into one flip-flopping line with a definite long-or-short answer. A rainbow refuses to give one, showing degrees of alignment instead; Supertrend suits rule-based execution while the stack suits regime assessment.

## FAQ

### What is the difference between a rainbow MA stack and an MA ribbon?

Mostly vocabulary, and usage overlaps. Ribbon typically means a handful of same-type averages with stepped lengths; rainbow usually implies a larger, gradient-colored set. In Widner's original Rainbow Charts each line is a recursive two-period smoothing of the previous line rather than a longer lookback on price, which gives the inner lines a slightly different lag character. The reading conventions are the same.

### How many moving averages does a rainbow use?

Widner's original construction used ten lines, the first a two-period average of price and each further line a two-period smoothing of the one before; most modern versions keep a similar count. The number is a readability choice, not a tuned parameter: fewer lines make crossings easier to see, more lines render compression and expansion more smoothly. What matters is spanning enough horizons to make regime shifts visible.

### Who invented Rainbow Charts?

Mel Widner published Rainbow Charts in Technical Analysis of Stocks & Commodities in July 1997, alongside a rainbow oscillator derived from the band. Plotting many ordinary moving averages together is a broader habit not tied to his article; his specific contribution was the recursive smoothing construction and the gradient presentation.

### What moving average lengths work best in a stack?

There is no evidence-backed optimum. Common choices are evenly stepped sets such as 10 through 100, Fibonacci-spaced lengths, or Widner's recursive build. Spacing mostly changes how smooth the fan looks, and any tuned set is one regime change away from looking mistuned.

### Do rainbow stacks lag the market?

Yes: every line is a smoothing of past prices, and the long end lags most. The short end reacts first and the geometry shows the disagreement, but a full flip of the band confirms a turn well after it began. Traders wanting earlier signals act on the inner lines or price itself, keeping the outer band as context.

### Can a rainbow stack be built from EMAs or volume-weighted averages?

Yes. Any average family works and the choice inherits its character: EMA stacks turn faster at the short end, volume-weighted stacks discount low-participation drift, smoother filters braid less in chop. Mixing families in one stack muddies the read, since crossings then reflect construction differences as much as market behavior.

## Implementations in the Library

- Rainbow MA Stack (LuxAlgo): https://www.luxalgo.com/library/indicator/rainbow-ma-stack/

## Related concepts

- SMA: https://www.luxalgo.com/library/concept/sma/
- EMA: https://www.luxalgo.com/library/concept/ema/
- Adaptive-lookback MA: https://www.luxalgo.com/library/concept/adaptive-lookback-ma/
- MA Envelope: https://www.luxalgo.com/library/concept/ma-envelope/
- SWMA: https://www.luxalgo.com/library/concept/swma/
- RMA: https://www.luxalgo.com/library/concept/rma/
- HMA: https://www.luxalgo.com/library/concept/hma/
- KAMA: https://www.luxalgo.com/library/concept/kama/
- JMA: https://www.luxalgo.com/library/concept/jma/
- ZLEMA: https://www.luxalgo.com/library/concept/zlema/

---

Source: https://www.luxalgo.com/library/concept/rainbow-ma-stack/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/