I am wrestling with this problem now since a few days and feel stuck ...
I don't quite understand how the DonchianChannel Indicator works for tick based strategies (even so I understand the simple code in the DonchianChannel.cs script!). It is not clear to me which OnBarUpdate method is called first: the one of the Indiciatorsadded toa Strategyvia Add()or theone of Strategy itself - presuming one has CalculateOnBarClose= false in the Strategy's Initialize() method?
For the DonchianChannel indicator (which by definition is NEVER crossed by the price)it makes a BIG difference which one is called first when one wants to trigger aDonchianChannel Breakoutsignal based on
1) Bars.CurrentBid > DonchianChannel(20).Upper[0] or
2) Bars.CurrentBid > DonchianChannel(20).Upper[1].
Neither one seems to work as expected.
The case 1) would work if the current bid (= Close[0] in historical backtesting) could WITHIN the current (unfinished) bar temporarily for the duration of one tick exceed the DonchianChannel(20).Upper[0]. This could be the case if the OnBarUpdate() method of the DonchianChannel indicator would be calledAFTER the one of the strategy oronly when the current bar is finished (either by time or # of ticks or volume). In other words, that would work if the Strategy would be updated at every tick and the DonchainChannel at the end of every finished bar.
But several tests showed me that 1) NEVER triggers an Entry order. So the next best thing I can do is 2), but that triggers an Entry orderTWO bars later than expected!
For greater clarity, I attached 2 files (in .zip) to explain this problem graphically- a screenshot of one of my test results andthe producing test script done with the Wizzard implementing 2) with either a CrossAbove() call (which doesn't trigger at all) or directly with the Bars.CurrentBid > DonchianChannel(20).Upper[1] condition.
No matter what I try, I can't ever trigger a signal like: Buy-at-Market when current bid or last pricepushesthe upper DonchianChannelup byat least one tick (== classic definition of aDonchian channel breakout).
It is clear to me (having programmed Donchian breakouts many times beforeon other platforms) that theMIN/MAX nature of Donchian is somewhat peculiar and great attention has to bepaidtoWHENEXACTLY the Channel and the bid/priceticks are updated. But in NT6beta11 I can't figure out how to do this correctly.
Any help or advice is deeply appreciated. TIA.
PS: I read and understood the previous relatedpost http://ninjatrader.mywowbb.com/forum16/1828.html but my problemseems different.
Comment