Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to create a base series?

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

    How to create a base series?

    Hello, I am trying to create an array to hold data such as when sma cross. Can I use something like
    MySeries = new Series<double>(this);
    If I can, create the array base to replace "this" in the example above. Since the array is not based on each bar, I would prefer not to use the array based on bar, such as BarsArray[1], etc.
    Thanks!

    #2
    Hello atrader,

    If you don't need a value for every bar, use a list.


    If you need to store multiple values (such as a bar number, and a double price) use a list of arrays.
    Something like:
    Code:
    private List<double[2]> myList = new List<double[2]>();
    myList.Add(new double[2] { CurrentBar, Close[0] } );
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea,

      Thank you so much for your information. One more question, how to make the index like the bar, that is each new added element has the index 0, the previous element has is 1 and so on. I know that I may have to define a fixed number of the elements for the list first and use a for loop to update the index for each element when adding new element. But this involves a lot of calculations. Is there a better way to do it?

      Thank you!

      Comment


        #4
        Hello Chelsea, I got it. Insert will solve the issue. Thanks!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        23 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        33 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        51 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        42 views
        0 likes
        Last Post CarlTrading  
        Working...
        X