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

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 Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,789 views
        0 likes
        Last Post aligator  
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        837 views
        0 likes
        Last Post emuns
        by emuns
         
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,294 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        13 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        11 responses
        63 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X