OPEN-SOURCE SCRIPT

CTA-min D1 — Donchian 55/20 Trend Breakout (ATR Risk)

245
What it is
A clean, daily trend-following breakout inspired by classic CTA/Turtle logic. It buys strength and sells weakness, then lets winners run with a channel-based trailing stop. No curve-fitting, no clutter—just rules.

How it trades

Timeframe: Daily (D1)

Entry: Close breaks the previous 55-bar Donchian channel (above for longs, below for shorts).

Exit/Trail: Trailing stop at the 20-bar Donchian channel on the opposite side (no fixed TP).

Risk: Initial stop = ATR(N) × stopMult (ATR is smoothed). Position size risks riskPct% of equity based on stop distance.

Labels: “BUY/SELL” only on the entry bar; “STOP BUY/STOP SELL” only on the exit bar.

Pyramiding: Off (one position at a time).

Regime Alignment with EMAs (recommended filter, not enforced by code)

Add EMA 50 and EMA 200 to the D1 chart.

Long bias: take BUY signals only when EMA50 > EMA200 (bullish regime).

Short bias: take SELL signals only when EMA50 < EMA200 (bearish regime).

Optional: for extra selectivity, require the H4 EMAs (50/200) to align with D1 before acting on a signal.

Inputs
entryN (55), exitN (20), atrLen (20), atrSmooth (10), stopMult (2.0), riskPct (0.5%–1.0% recommended).

Works well on (tested by user)
BTCUSD (Bitcoin), EURUSD, GBPJPY, NAS100/US100, USDJPY, AUDUSD, XAGUSD (Silver), US30 (Dow), JP225 (Nikkei), EURGBP, NZDUSD, EURCHF, USDCHF.

How to use
Apply to D1 charts. Review once per day after the daily close and execute next session open to mirror backtest assumptions. Best used as a portfolio strategy across multiple uncorrelated markets. Use the EMA alignment above as a discretionary regime filter to reduce false breakouts.

Notes
For educational use. Markets involve risk; past performance does not guarantee future results. Use responsible position sizing.

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。