Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Initialize Series<T>

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

    Initialize Series<T>

    How/Where do i initialize series?
    It's the same inside State.Historical.

    else if (State == State.DataLoaded)
    {
    IValuesTest = new Series<double>(this, MaximumBarsLookBack.Infinite);

    for(int i=0; i<IValuesTest.Count; i++)
    {
    IValuesTest[i] = 0.0; <======= Out Of Range
    }
    }

    #2
    in onbarupdate, when i populate some Serie<double> and run the following:

    int goodBars = 0;
    while(IValues.IsValidDataPoint(goodBars))
    goodBars += 1;
    Print("good bars onbarupadte"+goodBars);
    i have "good bars onbarupdate 736" for example.

    the same code inside onrender gives
    "good bars render 0"

    why is that?

    Comment


      #3
      Hello diff24rac,

      Thank you for the post.

      The help guide on the OnRender() method states the following:

      Unlike market data events and strategy order related events, there is NO guarantee that the barsAgo indexer used for Series<T> objects are in sync with the current bars in progress. As a result, you should favor using an absolute index method to look up values (e.g., <series>.GetValueAt(), Bars.GetOpen(), etc)
      More on OnRender here:


      Please try using <series>.GetValueAt() instead of literal indices. Also, ensure that the custom ISeries object is initialized at the class level so that all methods will have scope for it.

      namespace NinjaTrader.NinjaScript.Indicators
      {
      public class MyIndicator : Indicator
      {
      private Series<double> myDoubleSeries;

      Please let us know if we may be of any further assistance.

      Comment

      Latest Posts

      Collapse

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