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 fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,403 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by Shai Samuel, 07-02-2022, 02:46 PM
      4 responses
      94 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Started by DJ888, Yesterday, 10:57 PM
      0 responses
      6 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      158 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      8 views
      0 likes
      Last Post Belfortbucks  
      Working...
      X