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 cmoran13, 04-16-2026, 01:02 PM
        0 responses
        43 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        158 views
        2 likes
        Last Post CaptainJack  
        Working...
        X