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 benmarkal, Yesterday, 12:52 PM
        3 responses
        23 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by helpwanted, Today, 03:06 AM
        1 response
        19 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        11 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        244 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        388 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X