What Purple Magic does
The Purple Magic is the slow trend line of the AIMS suite. Because it is shifted 21 bars forward, the next 21 bars of the line are already known, so you can see the level the next bar will be measured against before it opens.
Shifted Trend Line
SMMA(34) of the bar midpoint, displaced 21 bars forward and drawn as circles or a solid line, with an optional glow and a projection tag on its leading end.
Closed-Bar Bias State
Bias flips bullish or bearish only when a bar closes. Choose whether a flip needs a close beyond the line or the whole candle clear of it.
Slope, Stretch & HTF Context
Slope reads Rising, Falling or Flat in ATR per bar, stretch measures distance from the line in ATR, and an optional higher-timeframe bias uses its last closed bar.
How to trade Purple Magic
Read the Bias
Use the dashboard bias as directional context: look for long setups while it reads Bullish and short setups while it reads Bearish.
Check the Slope
A Flat slope means the line is not trending. Expect more chop and more frequent flips, and be more selective.
Wait for a Retest
A retest marker shows the first bar that touched the line and closed back on the bias side. Use it as an area to look for entries with your own trigger.
Respect the Stretch
A stretch marker means price is far from the line in ATR terms. Moves often slow or pull back from there, so avoid chasing.
Prompts, not trade instructions. A SETUP READY prompt tells you to review the structure on a closed candle. It is never a command to enter blindly.
Setups and chart grammar
Every Purple Magic marker is set on a closed bar.
| Setup | Context | What the indicator sees | Goal |
|---|---|---|---|
| Bias Flip | Price crosses the line | A bar closes beyond the line (Close rule) or clears it entirely (Full candle rule) | Update directional context; a triangle marks the flip bar |
| Retest | Bias already established | The first bar that touches the line and closes back on the bias side | Look for an entry with your own trigger, in the direction of the bias |
| Stretch | Extended move away from the line | Distance from the line crosses the stretch threshold (default 3.0 ATR) | Treat as a caution signal: avoid chasing, expect slowing or a pullback |
Last closed-bar flip was above the line.
Last closed-bar flip was below the line.
Slope inside the flat band (default 0.02 ATR per bar).
Price beyond the stretch threshold (default 3.0 ATR).
The Closed-Bar Bias Invariant
Bias, flip, retest and stretch markers update on confirmed bars only. The line itself is a moving average and moves with each new bar; the higher-timeframe bias reads the previous closed bar of that timeframe.
PM(t) = SMMA(hl2, 34)[t - 21] Close rule: close > PM -> Bullish | close < PM -> Bearish Full candle: low > PM -> Bullish | high < PM -> Bearish

Settings
| Input | Type | Default | What it does |
|---|---|---|---|
| Length / Shift | Integer | 34 / 21 | SMMA length and forward shift of the Purple Magic line. |
| Source | Source | hl2 | Price source for the line (bar midpoint by default). |
| Line style | String | Circles | Circles or Line. |
| Line colour | String | Purple | Purple, or Slope to colour the line green rising, red falling, grey flat. |
| Flip rule | String | Close | Close: a close beyond the line flips bias. Full candle: the whole bar must clear the line. |
| ATR length | Integer | 14 | ATR period used for slope and stretch. |
| Slope lookback | Integer | 5 | Bars used to measure the slope of the line’s leading edge. |
| Flat band (ATR per bar) | Float | 0.02 | A slope smaller than this reads as Flat. |
| Stretch threshold (ATR) | Float | 3.0 | Distance from the line at which price reads as stretched. |
| Show HTF bias | Boolean | false | Adds the same rule on a higher timeframe (default D) to the dashboard. |
Frequently asked questions
It is a 34-period smoothed moving average (SMMA) of the bar midpoint, shifted 21 bars forward. The smoothing filters out noise and the shift draws the line ahead of price.



