Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      26 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      192 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,234 views
      0 likes
      Last Post xiinteractive  
      Working...
      X