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 Mindset, 04-21-2026, 06:46 AM
            0 responses
            88 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
            119 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