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 realblubb, Today, 09:28 AM
        0 responses
        1 view
        0 likes
        Last Post realblubb  
        Started by AaronKoRn, Yesterday, 09:49 PM
        1 response
        18 views
        0 likes
        Last Post Rikazkhan007  
        Started by ageeholdings, Today, 07:43 AM
        0 responses
        12 views
        0 likes
        Last Post ageeholdings  
        Started by pibrew, Today, 06:37 AM
        0 responses
        4 views
        0 likes
        Last Post pibrew
        by pibrew
         
        Started by rbeckmann05, Yesterday, 06:48 PM
        1 response
        14 views
        0 likes
        Last Post bltdavid  
        Working...
        X