I've come across an odd behavior and possibly a bug in regards to making custom indicators. In simulations on multiple instruments, the custom series sometimes get displaced on the x-axis.
I made a clean example to demonstrate. My indicator here simply returns the current close value (input value). As a test, I made this simple indicator both as a compiled dll and in a class in a RE project.
protected override double CalcNewValue(int index)
If I run this on any single instrument, and plot the indicator in a chart, it comes out just fine. See reSeries1.png attached. It even works fine with some combinations of instruments. No pattern found yet. If I run on many instruments, it fails. If I keep increasing the portfolio, one instrument at a time, it fails after a few are added. No pattern as to which instruments cause the problem. If it was fine with three instruments, and adding a fourth fails, it still fails if that fourth instrument is removed before the next run.
So what does fail mean? It means that the series got misaligned. See image reSeries2.png attached. Same function used. The indicator line is in effect showing the future.
I tried setting Synchronize Bars to both true and false, but no difference.
Am I missing something big here, or did I stumble upon a pretty serious bug?Update:
Further investigations tell me a couple of interesting points:
1. Even if the data is drawn wrong, it appears as if the series are in fact correct. I did a test in NewBar for (Close.Current == indicator.Current), which is always true as it should be. Even if the data is drawn like in image 2.
2. The problem seems related to LeadBars and only occurs if this property is set. Setting Data Start and Trade Start instead makes the whole problem go away.
Tuesday March 04 2014 by