Thesis
CCI-gated ATR ratchet — long on a bullish wick break of the trail, short on the mirror.
Fits Trend following setups — works best when the underlying market behavior matches the thesis, and breaks down when it doesn't. Pair with the backtester's walk-forward mode before committing real capital.
Selective entries — the wick-cross condition is strict, so trades fire only when momentum really pushes through. Strong in trending regimes, quiet during balanced ranges.
YAML rule-set
Paste this into the Strategy Designer's Text tab, or use the dashboard button above to load it as a template.
_template:
title: Trend Magic — CCI-gated ATR ratchet
category: trend_following
skill: intermediate
name: trend_magic
weight: 1.0
long_only: false
indicators:
tm:
kind: trend_magic
period: 20
atr_period: 5
coeff: 1.0
low_:
kind: sma
period: 1
source: low
high_:
kind: sma
period: 1
source: high
entry:
combine: OR
rules:
- combine: AND
direction: long
rules:
- {lhs: {indicator: low_}, op: crosses_up, rhs: {indicator: tm, field: trail}}
- combine: AND
direction: short
rules:
- {lhs: {indicator: high_}, op: crosses_down, rhs: {indicator: tm, field: trail}}
exit:
combine: OR
rules:
- {lhs: {indicator: tm, field: state}, op: crosses_down, rhs: {value: 0}}
- {lhs: {indicator: tm, field: state}, op: crosses_up, rhs: {value: 0}}
risk:
trailing_stop_pct: 0.04
cooldown_bars: 2
Indicators
tmTrend Magic (period 20, ATR 5, coeff 1.0)Port of KivancOzbilgic's Pine v4 Trend Magic: an SMA-of-TR ATR band ratcheted by the CCI(20) regime — up while CCI ≥ 0, down while CCI < 0.
low_ / high_SMA(1) wick wrappers (low / high)One-bar SMAs over low and high so the wick-based crossing predicates have tracked previous values. The native bar.low / bar.high collapse prev = now and never fire crossings.
Entry conditions
The bot opens a position the bar after every condition below has fired.
- Long when the bar's low wick crosses up through the Trend Magic trail line.
- Short when the high wick crosses down through the trail line.
Exit conditions
Any of the conditions below will close the position.
- CCI regime flip through zero closes the active position.
- 4% trailing stop, 2-bar cooldown.
Expected behavior
Selective entries — the wick-cross condition is strict, so trades fire only when momentum really pushes through. Strong in trending regimes, quiet during balanced ranges.
Equity-curve character, not a return forecast. Backtests are not promises about live performance.
Try it on your own data
Open the template in the dashboard to backtest it on BTC, ETH, or any CCXT symbol — or copy the YAML into the Strategy Designer to edit it first.
Past behavior on backtests is not a guarantee of future performance. Markets change; rule sets need re-validation. Trade at your own risk.