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 Tim-c, Today, 03:54 AM
      0 responses
      3 views
      0 likes
      Last Post Tim-c
      by Tim-c
       
      Started by FrancisMorro, Today, 03:24 AM
      0 responses
      2 views
      0 likes
      Last Post FrancisMorro  
      Started by Segwin, 05-07-2018, 02:15 PM
      10 responses
      1,771 views
      0 likes
      Last Post Leafcutter  
      Started by Rapine Heihei, 04-23-2024, 07:51 PM
      2 responses
      31 views
      0 likes
      Last Post Max238
      by Max238
       
      Started by Shansen, 08-30-2019, 10:18 PM
      24 responses
      945 views
      0 likes
      Last Post spwizard  
      Working...
      X