Donchian Channel Breakout Trading Strategy
Overview
The Donchian channel breakout trading strategy judges current price trends by calculating the channel of highest and lowest prices over a certain period and trades long and short based on channel breakouts. This strategy is suitable for highly volatile stocks and cryptocurrencies.
Strategy Logic
This strategy constructs a channel by calculating the highest price pcmax and lowest price pcmin over the last history periods. The calculation methods for the upper and lower rail of the channel are:
Upper rail yh = pcmax - (pcmax - pcmin) * (100 - percentDev)/100
Lower rail yl = pcmin + (pcmax - pcmin) * percentDev/100
where percentDev defaults to 13.
A long signal is generated when the price breaks through the upper rail. A short signal is generated when the price breaks through the lower rail.
The specific logic to generate trading signals is:
-
boundup = high > yh to determine if the upper rail is broken
-
bounddn = low < yl to determine if the lower rail is broken
-
upsign = sma(bounddn, 2) == 1 uses sma of bounddn to determine persistent breakout of lower rail
-
dnsign = sma(boundup, 2) == 1 uses sma of boundup to determine persistent breakout of upper rail
-
exitup = dnsign breakout of upper rail generates exit signal
-
exitdn = upsign breakout of lower rail generates exit signal
-
if upsign breakout of lower rail generates long signal
-
if dnsign breakout of upper rail generates short signal
The strategy also sets start and end trading times to avoid unnecessary overnight positions.
Advantages of the Strategy
-
Uses Donchian channel to determine trends, good backtest results
-
Has both long and short signals, allows two-way trading
-
Uses SMA to filter signals and avoid bad trades
-
Optional stop loss to control risks
-
Sets start and end trading times to avoid overnight risks
Risks of the Strategy
-
Sensitive to history and percentDev parameters, needs optimization for different products
-
May generate false signals in range-bound markets
-
Does not consider order management, may impact profitability in live trading
-
Does not consider position sizing, risks of oversized positions
-
Does not consider money management, needs reasonable trading capital
Enhancement Ideas
-
Optimize history and percentDev parameters for different products
-
Add filters to avoid false signals in ranging markets
-
Add position sizing module to control single position size
-
Add money management module to limit total position size
-
Add order management for optimal order execution
Conclusion
The Donchian channel breakout strategy uses channel breakouts to determine trends and trading signals, with good backtest results and ability to trade both long and short. However, risks exist regarding parameter optimization, filters, position sizing, money management, order management etc. Proper enhancements in these areas are needed before stable live trading. Overall, it is a traditional trend following strategy, and with optimizations can become a reliable quantitative trading strategy.
/*backtest
start: 2023-10-31 00:00:00
end: 2023-11-07 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
////////////////////////////////////////////////////////////
// Copyright by AlexInc v1.0 02/07/2018 @aav_1980
// PriceChannel strategy
// If you find this script helpful, you can also help me by sending donation to - 1

