Cannot access NamedSeries TimeSeries from barHistory
Initialize Exception (CallPut_TSLA.12.23.2021) Line 49 - Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at WealthLab.Core.DateSynchedList`1.get_Item(Int32 idx)
at WealthScript2.MyStrategy.Initialize(BarHistory putCallbars) in :line 49
at WealthLab.Backtest.UserStrategyExecutor.NewAlgo(List`1 symbols)
Initialize Exception (CallPut_TSLA.12.23.2021) Line 49 - Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at WealthLab.Core.DateSynchedList`1.get_Item(Int32 idx)
at WealthScript2.MyStrategy.Initialize(BarHistory putCallbars) in :line 49
at WealthLab.Backtest.UserStrategyExecutor.NewAlgo(List`1 symbols)
CODE:
BarHistory barPCr = GetHistory(bar, "PCR_" + bar.Symbol.Split('_')[1]); foreach (var ns in barPCr.NamedSeries) { WriteToDebugLog("KEY: " + ns.Key); TimeSeries TS = ns.Value; WriteToDebugLog("COUNT: " + TS.Count); Double a = TS[2]; TimeSeries tt = TS.Clone(); PlotTimeSeries(tt, ns.Key, "PCR", _baseColor, _line); }
Rename
Looks like there is no data at the bar #2 i.e. the bar count is less than 3.
If directly load the #2 bar from bar, it works fine. The namedseris has 249 data points.
What about the BarHistory object you sync with ("bar")?
The bar itself is fine. The close timeseries data is also fine in 2nd bar. The only issues are namedseries of 2nd bar.
The following code works
CODE:
//create the unsynchronized indicator BarHistory optionSpy = GetHistoryUnsynched("MAX_SPX.01.05.2022", HistoryScale.Minute5); TimeSeries maxVol = optionSpy.NamedSeries["max_volume_call"]; //sychrnize it with the data being processed maxVol = TimeSeriesSynchronizer.Synchronize(maxVol, bars); //Plot it PlotTimeSeries(maxVol, "Max Vol", "Vol", Color.Red);
Your Response
Post
Edit Post
Login is required