Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Chris L.NinjaTrader Customer Service

    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 aussugardefender, Today, 01:07 AM
      0 responses
      1 view
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      238 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      383 views
      1 like
      Last Post Gavini
      by Gavini
       
      Started by oviejo, Today, 12:28 AM
      0 responses
      1 view
      0 likes
      Last Post oviejo
      by oviejo
       
      Started by pechtri, 06-22-2023, 02:31 AM
      10 responses
      125 views
      0 likes
      Last Post Leeroy_Jenkins  
      Working...
      X