It's conceptually easy to write a multi-instrument indicator or strategy. In practice, it's pretty hard to make one that's robust, especially in the face of missing data bars.
It would be fairly easy if Closes[0][x] and Closes[1][x] always referred to the same time & date (for bars of the same time frame). But if either bar series is missing a bar, they don't, they refer to different times or dates. There are a lot of stocks etc. that sometimes have no trades over a 1-minute or 5-minute or longer periods. I've even seen stocks that got out of sync on daily bars.
It's quite a pain to write code that produces good results when bars are missing, but it can be done, and right now it must be done or you will sometimes have garbage for output.
There's a fairly simple solution that I'd like to suggest:
For indicators or strategies which have more than one bar series with the same time frame, you should have the option (settable in Initialize(), defaulting to On) to keep all bars in sync, by ignoring data unless all bar series of that time frame have data. If one bar series is missing a bar, throw away the bars of the other series even if they are present.
This would make it dramatically easier to write robust multi-instrument indicators and strategies. If programmers could be sure that Closes[0][x] and Closes[1][x] always referred to the same time/date, a whole lot of code/development time/debugging/testing/risk/learning curve/ goes away.
I expect that it won't really be very hard for you to implement. When processing incoming bars from realtime or from history, just throw away any bars for a time frame if there are any missing bars from that time frame. While it may sound wrong at first to throw away data, in a multi-instrument environment you really don't want the data from one instrument unless you have data from the other(s), and it's a whole lot of work to filter it out at the indicator/strategy level.
Thanks,
-Kevin

Comment