Hi,
I'm working with a strategy where the set of indicators & parameters is constantly changing.
Therefor I need to construct new Instances of the Indicator class on every bar (onBar).
A strategy coded in this way does run, but it is very slow and in backtesting after some hunderd bars I run into this OutOfMemory error.
I've verified that the calling the Indicator class construction at every bar is indeed the problem. If I construct the Indicators at OnStrategyStart, so with parameters kept constant during the simulation, there is no problem.
What approach would you suggest for my situation ?
Regards,
Frank
Quote:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Collections.Generic.SortedList`2.set_Capacity(Int32 value)
at System.Collections.Generic.SortedList`2.EnsureCapacity(Int32 min)
at System.Collections.Generic.SortedList`2.Insert(Int32 index, TKey key, TValue value)
at System.Collections.Generic.SortedList`2.set_Item(TKey key, TValue value)
at SmartQuant.Data.MemorySeries`1.Add(DateTime datetime, Object obj)
at SmartQuant.Indicators.Indicator.Add(DateTime DateTime, Double Data)
at SmartQuant.Indicators.EMA.Calculate(Int32 index)
at SmartQuant.Indicators.EMA.OnInputItemAdded(Object sender, DateTimeEventArgs EventArgs)
at SmartQuant.Indicators.Indicator.OnInputItemAdded2(Object sender, DateTimeEventArgs EventArgs)
at SmartQuant.Series.ItemAddedEventHandler.Invoke(Object sender, DateTimeEventArgs e)
at SmartQuant.Series.TimeSeries.EmitItemAdded(DateTime dateTime)
at SmartQuant.Series.BarSeries.Add(Bar bar)
at SmartQuant.Instruments.BarSeriesList.l9GsJ1Y3L(Instrument , Bar )
at SmartQuant.Instruments.DataManager.FXeMVYXvd(Object , BarEventArgs )
at SmartQuant.Providers.ProviderManager.donsPjTgF5(Object , BarEventArgs )
at SmartQuant.Providers.BarEventHandler.Invoke(Object sender, BarEventArgs args)
at SmartQuant.Simulation.SimulationDataProvider.oB8NQOfhqM(IFIXInstrument , Bar )
at SmartQuant.Simulation.SimulationDataProvider.QGYNAiGibJ(SeriesObjectEventArgs )
at SmartQuant.Simulation.SeriesObjectEventHandler.Invoke(SeriesObjectEventArgs args)
at SmartQuant.Simulation.Simulator.dEG48R9xls(IDataSeries , IDataObject )
at SmartQuant.Simulation.Simulator.Asx4Vq8104()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()