I've written a strategy that is working well for most trades. However, for one trade in the back-test series, it is not behaving correctly. To test why this is happeneing, I embedded the following code into my Strategy:
if( Position.MarketPosition == MarketPosition.Long && High[0] >= DonchianChannel(24).Upper[0] ) {
bool isEqual = (High[0] >= firstLongTarget);
bool does1equal1 = (92.59>=92.59);
Print( Time[0].ToString() +", Donchian Upper Met: "+High[0]+", firstLongTarget: "+firstLongTarget+ ", isEqual?: " + isEqual+". 1=1: "+ does1equal1 );
}
Here's the result this code produces in the Output Window:
10/1/2012 12:48:00 PM, Donchian Upper Met: 92.59, firstLongTarget: 92.59, isEqual?: False. 1=1: True
The problem with this result is that apparently High[0] = 92.59 and firstLongTarget = 92.59, but the comparison of the variables for equality is returning false. As you can see, comparing the two hard-coded numbers returns true. High[0] should be returning a double, and firstLongTarget is defined as a double in my code.
This is very confusing. Does printing double precision numbers in NT round them by default? This is the only explanation I can think of for this result. Any assistance anyone can provide would be greatly appreciated!
Comment