Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

C# arrays

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

    C# arrays

    I'm making an indicator to run on tick charts. I'm trying to build bars in arrays as I go so I can see bar values and the ticks on the chart:

    double[] open = newdouble [20] ;
    double[] high = newdouble [20] ;
    double[] low = newdouble [20] ;
    double[] close = newdouble [20] ;

    I tried the microsoft C# examples for working with arrays but have problems initializing and using them. Are there any examples that can get me out of the woods on this? Initialization of values seems to be a problem, and where to place the declaration with the initializations seems tricky too. If I initialize under the OnBarUpdate section it seems to get initialized every tick, if I try to declare the arrays in the initialize section they are not available to the OnBarUpdate section, etc., etc., etc...

    #2
    Unfortunately we have no samples on the usage of C# core components.

    Comment


      #3
      Maxpi.

      I did it as such:

      First declare the array in the variables section
      private double[] openArray;

      Next, in the
      Initialize()
      {
      openArray = new double[20];
      }

      You have to be sure you declare the variables in an area where they will be in the scope of the Initialize() and OnBarUpdate() sections.

      I'm not sure you need to do this to save the values; I think NT does it for you in a DataSeries. Dierk, can you confirm?
      mrlogik
      NinjaTrader Ecosystem Vendor - Purelogik Trading

      Comment


        #4
        Yes save as in store for the lifetime of the indicator.
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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