If you create a DataSeries synced to a different set of bars:
syncedToBarsArray1 = new DataSeries (SMA(BarsArray[1],10));
the DataSeries will not be synced to BarsArray[1], it will have strange behavior. If BarsArray[0] is a longer timeframe, it will sync to BarsArray[0]. If BarsArray[0] is a shorter timeframe, it appears to not sync to anything.
How to reproduce:
Install the attached strategy DataSeriesSyncTest. Run it on first on the instrument "SPY" set to 6 days of daily data. The strategy creates a secondary bar series of 30 minute bars, and a Data Series synced to it. In OnBarUpdate, it prints the [0] and [1] positions of each data series object.
When you run the strategy, you will see that the [1] position of the Data Series "syncedToBarsArray1" changes only daily, in sync with the primary bars.
Now run the strategy again, with the strategy set to use 10-minute bars as the primary. You will see that the [1] position of the Data Series "syncedToBarsArray1" never changes, and it generates an error message for indicator SMA on bar 10.
Also, is there a way to create a new Data Series, synchronized with a secondary bar series, without invoking SMA? Not only does it seem unintuitive (I don't won't to calculate an SMA), but I tried to do it from a "user defined method" and I couldn't because the compiler wouldn't allow it.
Another question: is there a way to create a Data Series that I can sync myself? i.e., it doesn't shift with any bar series, it shifts only when a method is called. This would be quite valuable.
Thanks,
Kevin

Comment