Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1687

 
What do your indexes and the amount of orders returned have to do with it? Create a couple of orders and loop through them. The loop will not be an array, but the number returned by OrdersTotal as a normal function, because it doesn't return the address of the array index where the orders are stored.
 

Array size is the number of array elements (or orders for example)

The first element has an index of 0, always,

the last one is one less than the array size.


If you want to create an array with one element, the only way to access that element is to use arr[0]. In all other cases, you will get an array overrun error.

It is the same with orders, just no error, but you cannot reach the first element (order) any other way.

 
Here is the reference https://www.mql5.com/ru/docs/array
Документация по MQL5: Операции с массивами
Документация по MQL5: Операции с массивами
  • www.mql5.com
Операции с массивами - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
I understand, OrdersTotal only gives the amount, but to refer to the order we use OrderSelect and here it already goes through the array. I have overlooked this point.
 
Yes, that's right. OrderSelect(0,


 
Nerd Trader an array index where the orders are stored.

You are not making a pass on a number, but on the list of orders in your trading account! And the number of orders is just a number... you can't make passes on it... how do you make a pass on a number 100? You don't... And on the list of 100 lines, we can make a pass of each line.

The number returned by OrdersTotal() is a prime number... It was designed in such a way that it ALWAYS coincides with the number of orders in the list.

If you know you only have 1 order at all times, then you only need to work with an order number "0" without any OrdersTotal()...

 
Nikolay Ivanov #:

You are not making a pass on a number, but on the list of orders in your trading account! And the number of orders is just a number... you can't make passes on it... how do you make a pass on a number 100? You don't... And on the list of 100 lines, we can make a pass of each line.

The number returned by OrdersTotal() is a prime number... It was designed in such a way that it ALWAYS coincides with the number of orders in the list.

If you know you only have 1 order at all times, then you just work with an order number "0" without any OrdersTotal()...

Aleksei Stepanenko #:

The array size is the number of array elements (or orders, for example)

The first element has an index 0, always,

the last one is one less than the array size.


If you want to create an array with one element, the only way to access it is to use arr[0]. In all other cases, you will get an array overrun error.

It is the same with orders, just no error, but you cannot reach the first element (order) any other way.

Yes, it is.
 
Nerd Trader use OrderSelect and it already goes through the array. I have overlooked this point.

The array (list) goes through a CYCLE. The OrderSelect only selects the order whose order number was created in this cycle for further work.

Документация по MQL5: Торговые функции / OrderSelect
Документация по MQL5: Торговые функции / OrderSelect
  • www.mql5.com
OrderSelect - Торговые функции - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Nerd Trader an array index where the orders are stored.
The thing is, the form is convenient in that by giving it the number of positions, it can fill any array. In my case everything would crash if 0 is fed, because the ArrayResize is tied to number of positions. On this reason I have additional condition if number of positions more than 0, then this loop. I mess up with it all the time too, now I've checked it again. The advice is correct, because otherwise the forte won't fill the zero element of the array, which is what the forte is for.
 
Great, friends, that we have a consensus