Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

More than 100 subsequent user events

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    More than 100 subsequent user events

    Ok. I have a small issue where by when I run my strategy using the associated indicator, I get the below error.
    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]);
    }

    #2
    Hello, thanks for your post.

    In the source code for DeltaMomentum, there is an extra override of OnMarketData and OnMarketDepth, please remove those from the source code first and test if this problem happens again.

    Remove:
    Code:
    protected override void OnMarketData(MarketDataEventArgs marketDataUpdate)
    {
    
    }
    
    protected override void OnMarketDepth(MarketDepthEventArgs marketDepthUpdate)
    {
    
    }
    I look forward to hearing of your results.

    Comment


      #3
      Ok. Looks like it is holding. Will continue to monitor over the next few days.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      87 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      134 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      118 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X