Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on calling "OnBarUpdate" method on bar 0

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

    #16
    Hello Conceptzx,

    Start by commenting out all of the other prints to focus on one thing at a time.

    At a print to the top of OnBarUpdate(), and comment out all other prints.

    Does that print appear?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      I seem to have narrowed the issue to the Enum cases, it doesn't seem to be finding the indicator.

      else if (State == State.DataLoaded)
      {
      double EntMaA = 0;

      switch (EntMaTypeA)
      {
      //case EntMaTypeA.ADXVMA: EntMaA = ADXVMA (Inputs[0], EntMaPeriodA)[0]; break;
      //case EntMaTypeA.DEMA: EntMaA = DEMA (Inputs[0], EntMaPeriodA)[0]; break;
      //case EntMaTypeA.DSMA: EntMaA = DSMA (Inputs[0], EntMaPeriodA)[0]; break;
      //case EntMaTypeA.EMA: EntMaA = EMA (Inputs[0], EntMaPeriodA)[0]; break;
      //case EntMaTypeA.HMA: EntMaA = HMA (Inputs[0], EntMaPeriodA)[0]; break;
      //case EntMaTypeA.KAMA: EntMaA = KAMA (Inputs[0], 2, EntMaPeriodA, 30)[0]; break;
      //case EntMaTypeA.PHMA: EntMaA = PHMA (Inputs[0], EntMaPeriodA)[0]; break;
      //case EntMaTypeA.PSMA: EntMaA = PSMA (Inputs[0], EntMaPeriodA)[0]; break;
      //case EntMaTypeA.PVMA: EntMaA = PVMA (Inputs[0], EntMaPeriodA)[0]; break;
      //case EntMaTypeA.PWMA: EntMaA = PWMA (Inputs[0], EntMaPeriodA)[0]; break;
      case EntMaTypeA.SMA: EntMaA = SMA (Inputs[0], EntMaPeriodA)[0]; break;​

      Comment


        #18
        Hello Conceptzx,

        To confirm, there is an issue with:
        EntMaA = SMA (Inputs[0], EntMaPeriodA)[0];


        The issue here, is that you cannot get any bar from the indicator until OnBarUpdate().
        The barsAgo [0] index would need to be removed and the indicator cached to an SMA type variable, or the code would need to be moved to OnBarUpdate().


        Are you attempting to follow the SampleUniversalMovingAverage example and assign the value to a series?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          That is correct. I still can't seem to figure out what's causing the issue. Now I'm getting unhandled exception pop-ups that crash ninja trader when I try to do anything with strategies. I

          'll just set what I have aside and start building one element at a time to see where it breaks.

          I'd like to make a feature request, a verbose option for printing everything ninja trader interprets from the code when it's loaded and running.

          Comment


            #20
            Hello Conceptzx,

            "I still can't seem to figure out what's causing the issue."

            You have implemented one of the changes I have suggested in post # 18?

            Which change did you implement?

            Is the error the same error?


            I'm not certain what you are meaning by "everything ninjatrader interprets"..

            You are wanting log messages like MyNinjaScriptName has called AddDataSeries, MyNinjaScriptName has assigned MyVariableName a value, MyNinjaScriptName has called the Print() method, etc?
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            45 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            21 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            31 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            50 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Working...
            X