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 Haiasi, 04-25-2024, 06:53 PM
      2 responses
      17 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      5 views
      0 likes
      Last Post Creamers  
      Started by Segwin, 05-07-2018, 02:15 PM
      12 responses
      1,786 views
      0 likes
      Last Post Leafcutter  
      Started by poplagelu, Today, 05:00 AM
      0 responses
      3 views
      0 likes
      Last Post poplagelu  
      Started by fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,408 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Working...
      X