Skip to main content
Trend Followingv2.0

AIMS Purple Magic

A slow trend line drawn 21 bars ahead of price: a 34-period SMMA of the bar midpoint with a closed-bar bias state, retest and stretch markers, and a dashboard that shows the next bar’s level in advance.

Shifted Purple Magic line, bias cloud, flip, retest and stretch markers with the dashboard — TradingView, US30 1h
AIMS Purple Magic on a US30 1h TradingView chart: shifted purple line with bias cloud, flip and retest markers, stretch diamonds, projection tag and dashboard
Type
Indicator
Category
Trend Following
Platforms
TradingView
Language
Pine v6
Repaints
No — closed bar
SMMA 34 · Shift 21Closed-Bar BiasRetest MarkersStretch in ATRHigher-Timeframe Bias

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

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

  2. Check the Slope

    A Flat slope means the line is not trending. Expect more chop and more frequent flips, and be more selective.

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

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

SetupContextWhat the indicator seesGoal
Bias FlipPrice crosses the lineA bar closes beyond the line (Close rule) or clears it entirely (Full candle rule)Update directional context; a triangle marks the flip bar
RetestBias already establishedThe first bar that touches the line and closes back on the bias sideLook for an entry with your own trigger, in the direction of the bias
StretchExtended move away from the lineDistance from the line crosses the stretch threshold (default 3.0 ATR)Treat as a caution signal: avoid chasing, expect slowing or a pullback
BULLISH

Last closed-bar flip was above the line.

BEARISH

Last closed-bar flip was below the line.

FLAT

Slope inside the flat band (default 0.02 ATR per bar).

STRETCHED

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
The line is drawn 21 bars ahead of price; the dashboard shows the level now and the next bar’s level — TradingView, US30 1h.
The line is drawn 21 bars ahead of price; the dashboard shows the level now and the next bar’s level — TradingView, US30 1h.

Settings

InputTypeDefaultWhat it does
Length / ShiftInteger34 / 21SMMA length and forward shift of the Purple Magic line.
SourceSourcehl2Price source for the line (bar midpoint by default).
Line styleStringCirclesCircles or Line.
Line colourStringPurplePurple, or Slope to colour the line green rising, red falling, grey flat.
Flip ruleStringCloseClose: a close beyond the line flips bias. Full candle: the whole bar must clear the line.
ATR lengthInteger14ATR period used for slope and stretch.
Slope lookbackInteger5Bars used to measure the slope of the line’s leading edge.
Flat band (ATR per bar)Float0.02A slope smaller than this reads as Flat.
Stretch threshold (ATR)Float3.0Distance from the line at which price reads as stretched.
Show HTF biasBooleanfalseAdds 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.

All indicators →

See the trend line before the bar opens.

AIMS Purple Magic is available on TradingView (invite-only) for iTradeAIMS members.