Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't input DataSeries to custom JMA

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

    Can't input DataSeries to custom JMA

    Hi! I have migrated my custom indicators to NT7b14 and it went rather smooth. But I have a problem with a custom JMA indicator, JMA(int Length, int Phase), that I use alot. I have finally figured out that the probelm occurs when one use a DataSeries as input to the JMA indicator . i.e. JMA(Close, Length, Phase). It then throws the error message:
    "Error on calling 'OnBarUpdate' method for indicator 'JMA' on bar 31: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart."

    This worked fine in NT 6.5. What could cause this problem in NT7?

    /Regards

    #2
    Do you have the code to check to make sure you have enough bars in JMA as this is what this error points too.



    Is JAM a MultiSeries indicator? Also, do you use arrays in JAM as these will also need to be checked live the above example.
    BrettNinjaTrader Product Management

    Comment


      #3
      poseidon_sthlm,

      If your indicator uses data points older than 256 bars you will want to be sure to create your DataSeries as one that uses Infinite bars lookback instead of using the new memory optimization features that limit it to 256.

      myDataSeries = new DataSeries(this, MaximumBarsLookBack.Infinite);

      Please be sure to also run the UI option when you add the indicator for max bars look back to infinite as well.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Thanks for your reply. I have isolated the problem with try- catch blocks and adjusted the code. The problem was that a DataSeries variable with index [1] was used when asigning another variable although no value had yet been asigned to the DataSeies variable. The indicator did also asign values to DataSeries variables directly without a set method.
        Code:
        if (i > 30)
        {
          dataSeries[0] = var1;
           var2 = dataSeries[0]  + dataSeries[1]; // On bar 31 yet no value has been asigned to dataSeries[1]
        }
        How come that this code didn't throw an error message in NT 6? And why does this code work in NT7 if you add the indicator to a primary barseries but not if you input a DataSeries variable to the indicator?

        Is it sufficient to use the stament
        (MaximumBarsLookBack = MaximumBarsLookBack.Infinite in the Initialize method
        or do you have to use the MaximumBarsLookBack.Infinite argumnet when initializing a new DataSeries too?
        (myDataSeries = new DataSeries(this, MaximumBarsLookBack.Infinite);

        /Regards

        Comment


          #5
          Hello,

          Just wanted to let you know that we recieved your note and you will get a response from me or another NinjaScript support team member soon.

          Thank you for your patience.
          BrettNinjaTrader Product Management

          Comment


            #6
            You will have to use the new DataSeries(this, MaximumBarsLookBack.Infinite) if you are trying to use infinite for your DataSeries.

            In 6.5 and 7, either of them, you would want to be checking that you have actually set values otherwise you will get invalid values anyways.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            605 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            351 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            561 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X