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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    156 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    90 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    140 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    130 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X