after over 4 hours of intense testing, I finally nailed down a serious bug in calling the Update() method within an indicator parameters.
In order to make this easily reproduceable I have attached a complete sample, so you can see this in action. It is an indicator as well as a strategy which is using this indicator.
For this demo -> the indicator is doing nothing but Printing the CurrentBar Number into the Output window to show its current Index. The indicator also has a public parameter e.g. price - the content of it is non relevant for this case. In order to access this parameter in a strategy we need to call Update() in the get accessor like we are used from NT7...
[Browsable(false)] public double Price { get { Update(); return price; } }
Now the strategy is using this indicator and retrieving the price in the OnBarUpdate. So far everything is fine... But now comes the serious issue.
If the indicator is using an additional DataSeries and the strategy is calling the Price multiple times (like in the example) -> so it is calling the Update() method multiple times in one Strategies OnBarUpdate cycle, the indicator is going out of sync! You can see this in the Output window how the CurrentBar numbers are now different and how the time stamps don't align anymore!
So there is a problem within the Update() method. Once there are additional DataSeries added to the indicator EACH time we call the Update() causes the indicators currentBar index to increase by 1 - thus going immeadently out of sync for all future calls from the strategy...
I hope I could explain it enough so you can fix that pretty quick, otherwise feel free to ask - really a nasty bug and I can't do any backtesting at the moment due to this problem! Maybe I can make a workaround with some Series<T> object instead of the Update() - but since I have converted a strategy from NT7 to NT8 I wanted to keep it the same.
Are there any license discounts for finding such evil bugs????
Kind regards,
Oliver
P.S. used NT version is Beta12
Comment