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.
- 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.
Rename
Cannot reproduce. This is probably specific to your symbol/DataSet and/or the strategy. Could you narrow it down to a reproducible test case?
Do you have a private place or email where I can drop the strategy?
I use 1-minute interval, SPY on IQFeed.
I use 1-minute interval, SPY on IQFeed.
If you believe it's the particular compiled strategy, please try to isolate the issue in an area of your solution first. Thanks.
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); } } } } }
Note: the strategy doesn't need to be a compile strategy and can remove the indicator too, but still I get the error.
I can duplicate it.. let's get @Glitch to look at it.
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.
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.
We have it fixed, it was a conflict placing trades on external symbols within a MetaStrategy.
Your Response
Post
Edit Post
Login is required