Breakout trading strategy: a Donchian channel example
By Oalgo · Last reviewed
A breakout strategy enters when price moves beyond the range of the last N candles. A common rule uses a Donchian channel: enter when the close is above the highest high of the last 20 candles, and exit when it falls back to the middle of the channel.
What are the rules of a breakout strategy?
#- The Donchian channel (20 candles) has an upper line (the highest high), a lower line (the lowest low) and a middle line (the average of the two).
- Entry: the close is above the upper line as it stood one candle earlier.
- Exit: the close falls below the middle line. A slower rule waits for the lower line.
- Stop: a Stop Loss as a percentage. The ATR stop loss page covers sizing it to volatility.
Why compare with the line one candle earlier?
#The channel includes the current candle. Today's high is already inside the highest high, and the close can never be above the high, so "close above today's upper line" can never be true. The rule has to look at the upper line from the candle before.
How do you write this strategy in Oalgo?
#In Oalgo you can tell Oalgo AI your breakout rule in your own words, check the rule it builds, and test it. After testing, if you choose, you Go Live with your own Live Strategy on your own Venue Account at a Supported Venue.
For example, you could tell Oalgo AI: "Enter when the close is above the 20-candle Donchian upper line from one candle ago. Exit when the close falls below the Donchian middle line. Use a 2% Stop Loss and a 5% exit target." These numbers are examples to change. In the builder, the Lookback condition with Bars Ago set to 1 reads a value from one candle earlier. A Live Strategy needs a stop on each side it can enter, and an exit target is optional. The example names both.
How do you test this strategy honestly?
#- Run a backtest on a quiet, sideways range and on a trending range. A breakout rule behaves very differently in each.
- Check the fees and the number of trades. Many breakouts do not hold, and each failed one still pays fees.
- Try other channel lengths, for example 10 and 30 candles. A rule that only holds at one length may be fitted to the past.
- Run a forward test on new prices, with simulated funds.
What can a breakout strategy not tell you?
#A close above a recent high does not say price will keep going. Price often moves back into the range, and the rule has entered at the top of it. A breakout rule also enters late, after the move has begun, and the stop can be a long way below. The trend following page puts it next to other trend rules.
Read next
- Trend following strategy: rules and how to test themA trend following strategy enters in the direction of a trend and exits when it ends. See the common rules, where each is explained, and how to test them.
- ATR stop loss: how to size a stop to volatilityAn ATR stop sets the stop distance as a multiple of ATR, so it is wider when price moves more. See the idea, a worked example, and how to test it.