Is the published strategy 'Dual Donchian Breakout' correct? Shouldn't the Short Stop level be "Low is less than Lowest(Low, 20) of 1 bar ago" -- 20 instead of 120?

What I see:

0
656
Solved
5 Replies

Bookmark

Sort
20 instead of 120 is not the biggest issue. The rationale is to trade 20-bar breakouts while there was a 120-bar breakout (vice versa for short trades). The strategy always act on that 120-bar breakout which is wrong. Instead, it should keep looking in the direction set by the preceding 120-bar breakout to choose the direction of trades.

As there doesn't seem to be an easy way to implement such rule with Blocks, we took down the strategy in the Builder. Let's think about replacing it with a "Lite" version later.
0
To anyone interested, here's the C# code version of it that acts correctly:

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript3 { public class DualDonchianBreakout : UserStrategyBase {       public DualDonchianBreakout()       {          AddParameter("Longer Channel", ParameterTypes.Int32, 120, 90, 300, 30);          AddParameter("Shorter Channel", ParameterTypes.Int32, 20, 5, 80, 5);       }       public override void Initialize(BarHistory bars) {          longChannelPeriod = Parameters[0].AsInt;          shortChannelPeriod = Parameters[1].AsInt;                    High120 = Highest.Series(bars.High, longChannelPeriod) >>1;          Low120 = Lowest.Series(bars.Low, longChannelPeriod) >>1;          High20 = Highest.Series(bars.High, shortChannelPeriod) >>1;          Low20 = Lowest.Series(bars.Low, shortChannelPeriod) >> 1;          PlotTimeSeries(High120, "Longer Channel High", "Price", Color.Green);          PlotTimeSeries(Low120, "Longer Channel Low", "Price", Color.Red);          PlotTimeSeries(High20, "Shorter Channel High", "Price", Color.Blue);          PlotTimeSeries(Low20, "Shorter Channel Low", "Price", Color.Fuchsia);          canEnterLong = false; canEnterShort = false;          StartIndex =Math.Max(longChannelPeriod, shortChannelPeriod);       } public override void Execute(BarHistory bars, int bar) {          var IsLastPositionActive = HasOpenPosition(bars, PositionType.Long) || HasOpenPosition(bars, PositionType.Short);           if (IsLastPositionActive) {             Position Pos = LastPosition;             ClosePosition(Pos, OrderType.Stop, Pos.PositionType == PositionType.Long ? Low20[bar] : High20[bar]); } else {             int _barXO = (int)CrossOverBar.Series(bars.High, High120)[bar];             int _barXU = (int)CrossUnderBar.Series(bars.Low, Low120)[bar];                          if (!canEnterLong)                canEnterLong = (_barXO > -1 && _barXU > -1 && _barXO > _barXU);             if (!canEnterShort)                canEnterShort = (_barXO > -1 && _barXU > -1 && _barXO < _barXU);             if (canEnterLong)             {                var t = PlaceTrade(bars, TransactionType.Buy,OrderType.Stop, High20[bar]);                if(t.Quantity > 0 )                   canEnterLong = false;             }             else                if (canEnterShort)             {                var t = PlaceTrade(bars, TransactionType.Short,OrderType.Stop, Low20[bar]);                if(t.Quantity > 0 )                   canEnterShort = false;             } } }       int longChannelPeriod, shortChannelPeriod;       TimeSeries High120, Low120, High20, Low20;       bool canEnterLong, canEnterShort;    } }
0
The fix I had in the original post would have been for a normal Donchian breakout.

What I was expecting with a dual version was something like...

Sell using Lowest(Low, 10)
Short using Lowest(Low,20)
Cover using Highest(High, 10)

You'll notice that the exit period is shorter than the enter period. I assume you could do something like that with blocks. Perhaps that's what you were considering for a lite version.

I just knew something seemed wrong with published strategy. Thanks for correcting it quickly.
0
Hi Eugene,

Can I ask why is the Dual Donchian Breakout, one of the WL.com published strategies, showing slightly different profits in two separate backtests despite these two backtests having the same c# code and strategy settings?

Please refer to the following screenshots for details. I have circled the profits at the bottom of each screenshot to highlight the differences.

pmbf
0
Hi,

It may be optimal if you troubleshoot it on your end position by position to spot for differences.

Nonetheless, recently I uploaded a fix to the strategy. Make sure you're running the up to date version.

0