Sometimes the strategy would be working fine for hours then it throws that error. Other times I cannot get it start due to it throwing that error. I have to wait a few more bars sometimes then it starts, but crashes later on. If I do market replay, it doesn't crash, I can play 3 months of Market replay one time and it doesn't crash, but go live and there it is. Sporadic. Even when the indicator loads to the chart, if I reload the ninjascript I get the error also.
Please let me know how I can avoid this. Thanks.
I am using the indicator DeltaMomentum that is available on the NInjatrader ecosystem.
Indicator 'irDeltaMomentum': Error on calling 'OnBarUpdate' method on bar 7832: More than 100 subsequent user events
Strategy 'DeltaScalper5': Error on calling 'OnBarUpdate' method on bar 7833: Object reference not set to an instance of an object.
Disabling NinjaScript strategy 'DeltaScalper5/159561905'
code Snipets.
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Tick, 1);
}
else if (State == State.DataLoaded)
{
irDeltaMomentum1 = irDeltaMomentum(Close);
AddChartIndicator(irDeltaMomentum1);
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if ( CurrentBar <500)
return;
Print("Called on Bar");
if (Bars.IsFirstBarOfSession || ToTime(Time[0]) < 020000 )
{
// _so.TrailEma.Checked=true;
// Store the strategy's prior cumulated realized profit and number of trades
RunOnce=false;
priorTradesCount = SystemPerformance.AllTrades.Count;
priorTradesCumProfit = SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit;
CalledStop=false;
if (Bars.IsFirstBarOfSession)
Print(irDeltaMomentum1.DownMomo[0]);
}
Comment