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 NullPointStrategies, Today, 05:17 AM
            0 responses
            52 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            130 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            70 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            44 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            49 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X