- ago
The following code demonstrates that repeated exceptions will occur even if you correct an offending line. The only way to get the exception to stop is to close the strategy and re-open it.

Here is the initial code that runs fine...

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; namespace WealthScript7 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          var wrapper = new TimeSeriesIndicatorWrapper(bars.Close);          scaledClose = new ScaledInd(bars, wrapper, HistoryScale.Minute5);          PlotIndicator(scaledClose, WLColor.Cyan);          StartIndex = 6;       } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { }       //declare private variables below       ScaledInd scaledClose;    } }


Now, change the the following line:

var wrapper = new TimeSeriesIndicatorWrapper(bars.Close);

to:

var wrapper = new TimeSeriesIndicatorWrapper(bars.Close >> 1);

The above causes the exception.

But, now change the line:

var wrapper = new TimeSeriesIndicatorWrapper(bars.Close >> 1);

back to:

var wrapper = new TimeSeriesIndicatorWrapper(bars.Close);

Save the strategy and run it. You get the same exception even though you changed the code back to the initial code that ran fine. The only way out of this that I found is to close the strategy and re-open it.

Here is the stack:

System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
at WealthLab.ChartWPF.PriceValuesLabel.SearchContainer()
at WealthLab.ChartWPF.PriceValuesLabel.set_Bars(BarHistory value)
at WealthLab.ChartWPF.CoreChart.AssignBars(BarHistory value, Boolean setOffsetZero, Boolean force, Boolean calledFromStreaming)
at WealthLab.ChartWPF.CoreChart.SetupStrategyItems(StrategyBase sb, BarHistory bars, Backtester bt)
at WealthLab8.cwStrategy.AssetWriter(BarHistory i, StrategyBase caller)
at WealthLab8.cwStrategy.RegisterWriter(Object instance, EventArgs selection)
at System.Windows.Threading.DispatcherTimer.FireTick()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)


Edit: WL build is 70.
0
110
Solved
1 Replies

Reply

Bookmark

Sort
Glitch8
 ( 9.89% )
- ago
#1
Ok you found a very particular series of esoteric steps that causes an exception and also found a way to work around this. Thanks for the report but I think this is probably a low priority item.
0
Best Answer

Reply

Bookmark

Sort