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 NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        55 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        132 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X