I have a UserDefinedMethod called DoPrint which essentially does Print with a timestamp, instrument and a model identifier tag.
In OnStartUp, I have included one of these DoPrints, which call Times[0][0] (to get the timestamp). In a single instrument/TF strategy, this works fine and the strategy performs as normal.
However, when I add another instrument or TF and try running/backtesting the strategy, I get this error:
**NT** Error on calling 'OnStartUp' method for strategy 'FW/e4d9e5b45b0746a8a04b5cf1bda2ebcf': Bar index needs to be greater/equal 0
I have troubleshooted and found that the problem lies with Times[0][0]. If I do not use my DoPrint method or if I use a modified DoPrint method which doesn't include Times[0][0], it works fine. I have even tried several iterations of BarsInProgress with no luck.
In this case, having the time of a bar printed OnStartUp is not relevant, and I could get around this problem by hardcoding a Print(ModelID + " Message") into the strategy instead so it is not a major problem. However, I am just interested to know why this is the case for only multi instrument strategies or if there is another workaround possible so that I can continue to use my DoPrint method for consistency?
Thanks

Comment