Trend Magic
By LuxAlgoApr 25, 2026
Trend Magic is an indicator on Vela, our next-generation charting platform, written in Pine Script®.
Trend Magic is the definitive clean build of the Trend Magic trailing line, a two-state regime tool steered by momentum rather than by price touching the line. While the CCI holds at or above zero the line rides below price at the low minus an ATR offset, ratcheting only upward; once the CCI turns negative it jumps above price and ratchets only downward. A gradient fill spans the room left between price and the ratcheted level.
How to Trade the Trend Magic?
- Bullish flip: the CCI crosses up through zero and the line resets below price. The long regime begins with a rising floor.
- Bearish flip: the sign turns negative and the line resets above price with a descending ceiling.
- Line tests: because flips are CCI-gated, price can touch or even pierce the trailing level without ending the regime, the trailing-stop reference event, alerted separately for each side.
Within a state the line never gives ground, which is what makes it usable as a ratcheted exit level: longs trail against the rising line, shorts against the falling one. The ATR multiplier moves the line closer or further without changing when it flips.
Trend Magic Settings
- CCI Length (default 20): lookback of the steering oscillator. Shorter lengths flip earlier but whipsaw more; longer ones lag turns.
- CCI Source (default hlc3): typical price, matching the classic CCI construction.
- ATR Length (default 5): averaging window of the offset that sizes the line's distance.
- ATR Multiplier (default 1.0): ATRs between price and the line; it sets distance only, never timing.
- Style toggles cover flip markers, the gradient trail fill, the regime colors and line width.
Frequently Asked Questions
Free to use
Run it on Vela. Go further with a paid plan.
- Up to 500 Custom Alerts, with webhook automation
- Up to 10× the chart history of Free
- Orderflow lookback up to full history
- More Quant usage to customize it, plus extra usage when you need it
- Futures data alongside crypto, stocks, forex and commodities
Related indicators
Run it on Vela. Make it yours with Quant.
Open this indicator free on Vela, our next-generation charting platform. Then ask Quant, our coding agent built into Vela, to retune it or turn it into a backtested strategy of your own.





