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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    238 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    154 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    163 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    246 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    199 views
    0 likes
    Last Post CarlTrading  
    Working...
    X