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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    63 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    90 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    47 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    105 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    63 views
    0 likes
    Last Post PaulMohn  
    Working...
    X