The Donchian Channels (Amibroker Code And Tradestation Code)
The original article can be found here.
The strategy in plain English:
The strategy is based on the “upside down” version of Donchian Channels mentioned in the article, ie. we buy on a breakdown of the lower channel/band.
- Create a lower band of the lowest low over the last 5 days.
- If the close crosses below the lower band, go long at the close.
- Sell at the close when the close is higher than yesterday’s close.
The Donchian Channels with optimization (Amibroker code):
oddis=Optimize(“days”,40,10,50,5);
oddis1=Optimize(“days”,20,10,50,5);
DonchianUpper=HHV(H,oddis);
DonchianLower=llV(l,oddis1);
DonchianMiddle=MA((DonchianUpper+DonchianLower)/2,20);
Plot(DonchianUpper,”DonchianUpper”,colorRed,styleLine);
Plot(DonchianLower,”DonchianLower”,colorRed,styleLine);
Buy= Cross(Close,Ref(DonchianUpper,-1));
buyPrice=Close;
Sell=Cross(Ref(DonchianLower,-1),Close);
sellPrice=Close ;
The code for the best and optimized option looks like this:
DonchianLower=llV(l,5);
Buy= Cross(Ref(Donchianlower,-1),Close);
buyPrice=Close;
Sell=Close>Ref(H,-1);
sellPrice=Close ;
Tradestation code:
If c crosses under lowest(low,5)[1] then buy this bar at close;
If c > h[1] then Sell this bar at close;
