- ago
Steps:
- Create a compiled strategy and make sure it generates trades.
- Create a new MetaStrategy and drop the Compiled Strategy you just created into it.
- Fill in Symbol, Port Weight and scale with appropriate date .
- Run it.
Error: Object Reference not set to an instance of an object.

Note: I debugged the compiled strategy. As soon as the first trade is made WL doesn't come back and generates the error.
0
333
Solved
8 Replies

Reply

Bookmark

Sort
- ago
#1
Cannot reproduce. This is probably specific to your symbol/DataSet and/or the strategy. Could you narrow it down to a reproducible test case?
0
- ago
#2
Do you have a private place or email where I can drop the strategy?

I use 1-minute interval, SPY on IQFeed.

0
- ago
#3
If you believe it's the particular compiled strategy, please try to isolate the issue in an area of your solution first. Thanks.
0
- ago
#4
here is a sample code of a strategy with the issue. I think the error has to do with indicators.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; using WealthLab.Data; using WealthLab.AdvancedSmoothers; namespace WealthScript4 {    public class TestMetaData : UserStrategyBase    {       int yesterdayBar = 0;       Double equityAtStart;       double startofDay;       BarHistory spyBars;       double high12, low12;       TimeSeries aTRu;       double trueRange = 0;       int barTime = 0;       public override void Initialize(BarHistory bars)       {          spyBars = GetHistory(bars, "SPY");          StartIndex = 100;          //startofDay = equityAtStart = CurrentEquity;          aTRu = ATRP.Series(spyBars, 18);       }       public override void Execute(BarHistory bars, int bar)       {          barTime = bars.DateTimes[bar].Hour * 100 + bars.DateTimes[bar].Minute;          if (bars.DateTimes[bar].Day != bars.DateTimes[bar - 1].Day)          {             DrawLine(bar, 1.0, bar, bars.Close[bar] * 3, WLColor.FromRgb(12, 16, 82), 2, LineStyle.Solid, "Price");             yesterdayBar = bar - 1;             startofDay = CurrentEquity;          }          trueRange = aTRu[bar];          high12 = spyBars.Close.GetHighest(bar, 12);          low12 = spyBars.Close.GetLowest(bar, 12);          if (!HasOpenPosition(bars, PositionType.Long))          {             if (bars.DateTimes[bar].DayOfWeek == DayOfWeek.Monday)             {                PlaceTrade(spyBars, TransactionType.Buy, OrderType.Market);             }          }          else          {             if (bars.DateTimes[bar].DayOfWeek == DayOfWeek.Friday)             {                ClosePosition(LastOpenPosition, OrderType.Market);             }          }       }    } }
0
- ago
#5
Note: the strategy doesn't need to be a compile strategy and can remove the indicator too, but still I get the error.

0
Cone8
 ( 28.32% )
- ago
#6
I can duplicate it.. let's get @Glitch to look at it.
0
- ago
#7
Thanks.
Note: if you remove this line (GetHostory())
spyBars = GetHistory(bars, "SPY");

Or add spyBars = null; before it to force releasing the history then it works.

then it works, but I use such a statement in many strategies to get data of supporting symbols.

0
Glitch8
 ( 12.10% )
- ago
#8
We have it fixed, it was a conflict placing trades on external symbols within a MetaStrategy.
0
Best Answer

Reply

Bookmark

Sort