Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

2D array to store the prices

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

    2D array to store the prices

    Hello,

    I'm creating a two-dimensional array to store the prices in.

    private double[,] priceArray = new double[1,200];

    An entry must be made when some condition is met.

    if(conditions)
    {
    priceArray[0, 0] = Close[0];
    }
    When, in the future, the price crosses the price from this array, the sign is drawn on the chart.

    But it turns out that the array priceArray[0, x] for all x contains only one last price value.

    ​Please tell me what am I missing.

    Regards

    #2
    Hello zhiga,

    Below is a link to the microsoft documentation on multidemensional arrays.
    Store multiple variables of the same type in an array data structure in C#. Declare an array by specifying a type or specify Object to store any type.


    If you are trying to save price values with bar numbers, you may want a dictionary or a keyvaluepair. Either would be general to C#.

    It looks like you are only assigning priceArray[0, 0] a value.

    Try assigning priceArray[0, 1] a value.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    663 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    376 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X