Join today
Strategies / Breakout / Donchian MACD Breakout

Donchian MACD Breakout: Channel Breaks With Momentum Filters

Longs trigger when the close breaks above the previous 9-bar high while the MACD histogram is rising, RSI(4) is above 63 and price holds above the 50 SMA. Shorts use a 7-bar low, a falling histogram, RSI(4) under 31 and the 500 SMA. Positions exit at the opposite channel edge with no profit target.

BreakoutLong & shortSwingNot yet tested
This strategy has not been backtested yet. The rules and code are published now, and the numbers will appear here after the first runs.

Entry rules, long

  1. Close crosses above the previous 9-bar high
  2. Members only
  3. RSI(4) above 63
  4. Close at or above the 50-period SMA

Entry rules, short

  1. Close crosses below the previous 7-bar low
  2. Members only
  3. RSI(4) below 31
  4. Close at or below the 500-period SMA

Exit rules

  1. Members only
  2. Shorts stop out at the 7-bar high
  3. No profit target

Parameters

positionSize
Shares per trade, as published
2
longChannelPeriod
Donchian length for long entries and the long stop
9
shortChannelPeriod
Donchian length for short entries and the short stop
7
macdFast
MACD fast length
12
macdSlow
MACD slow length
26
macdSignalPeriod
MACD signal length
9
rsiPeriod
RSI length
4
longRsiLevel
RSI must be above this to buy
63
shortRsiLevel
RSI must be below this to short
31
longTrendPeriod
SMA the close must be at or above to buy
50
shortTrendPeriod
SMA the close must be at or below to short
500

The code

ProBuilder, rewritten to house standard

Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.

// ============================================================
// Donchian MACD Breakout
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Breakout
// Direction: Long & short
// Timeframe tested: Not yet tested
// ============================================================

// --- Settings ---
DEFPARAM CumulateOrders = false
DEFPARAM PreloadBars = 50000

// --- Parameters ---
positionSize = 2            // shares per trade, as published
longChannelPeriod = 9       // Donchian length for long entries and the long stop
shortChannelPeriod = 7      // Donchian length for short entries and the short stop
macdFast = 12               // MACD fast length
macdSlow = 26               // MACD slow length
macdSignalPeriod = 9        // MACD signal length
rsiPeriod = 4               // RSI length
longRsiLevel = 63           // RSI must be above this to buy
shortRsiLevel = 31          // RSI must be below this to short
longTrendPeriod = 50        // SMA the close must be at or above to buy
shortTrendPeriod = 500      // SMA the close must be at or below to short

// --- Indicators ---
macdHistogram = MACD[macdFast, macdSlow, macdSignalPeriod](close)
longChannelHigh = Highest[longChannelPeriod](high)
longChannelLow = Lowest[longChannelPeriod](low)
shortChannelHigh = Highest[shortChannelPeriod](high)
shortChannelLow = Lowest[shortChannelPeriod](low)
rsiValue = RSI[rsiPeriod](close)
longTrendMA = Average[longTrendPeriod](close)
shortTrendMA = Average[shortTrendPeriod](close)

20 more lines: the entry and exit rules.

Read this first

Known weaknesses

  • This strategy has not been backtested yet, so there are no results to judge it by.
  • There is no profit target. Trades only end at the channel stop, so gains can shrink before the exit triggers.
  • Long and short sides use different settings (9 versus 7 bars, 50 versus 500 SMA), which adds parameters that may be fitted to one market.
  • The code trades 2 shares by default and has not been compile-checked after the rewrite.

Indicators used

Donchian ChannelMACDRSISMA

How to load it

  1. Copy the code with the copy button above the code block.
  2. In ProRealTime, open a chart of the instrument and timeframe you want to test, then open ProOrder > New trading system and choose "Create with programming".
  3. Paste the code, give the system a name and save it.
  4. Click "Backtest", set your own spread and position size, and run it before you consider trading it live.

Questions

About this strategy

Can it run in ProOrder?

The rules are written for ProOrder, but the rewritten code has not been compile-checked or backtested. Treat it as a starting point for your own testing.

Which instruments has it been tested on?

None yet. It has not been backtested on this site.

What position size does the code use?

The default is 2 per trade, set by the positionSize parameter. Without a backtest there is no drawdown figure, so size small until you have your own results.

Which timeframe should I test first?

The 500 SMA filter on shorts needs a lot of history, so a timeframe with long data coverage makes sense. No timeframe has been tested here yet.

Related

Strategies like this one

Bollinger Squeeze

Uses the same indicator.

14.30 PF · 86 trades

Breakout Regime Filter

Also a breakout strategy.

6.28 PF · 70 trades

Bollinger Band Walk

Also a breakout strategy.

3.10 PF · 148 trades

Want to know when this one gets tested? Join the ProRealAlgos community waitlist.

The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.

Past backtest results do not guarantee future results. This is not financial advice. Curated and maintained by ProRealAlgos. ProRealTime™ is a trademark of ProRealTime SAS. prorealalgos.comStatsDocs