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

 
Valeriy Yastremskiy #:

I.e. it is only a question of localising the use for local areas with the same argument names by reference. Well, not much, but there is something. Thought there was more to it.

These are just the things I know I'm comfortable with. Surely there are other advantages, such as memory redundancy or something else. Why don't you ask Fedoseev directly?
 
Alexey Viktorov #:
That's just what I know about, what's comfortable for me. Surely there are other benefits, such as memory redundancy or whatever. Why don't you ask Fedoseev directly?

Different level of perception))) Maybe I sin myself, obvious things are very difficult to convey to others))))

 
Valeriy Yastremskiy #:

It is possible to do with one argument x by declaring r in global scope.

One can do without arguments at all by declaring x in global scope. Moreover, it is possible not to return the result, but to write it into global variable. But it will lead to code confusion, necessity to remember what and where is stored, and with increasing program code it will turn the programmer's life into hell.
 
Good afternoon. Could you please tell me what is missing? My purpose is to close the very first trades with minimal volume. I am currently selecting only orders with a volume of 0.01.
     for(int i=0; i<OrdersTotal(); i++){
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)){
       if(OrderLots()==0.01){ 
     OrderClose(OrderTicket(),0.01,OrderType()==OP_BUY?Bid:Ask,3,clrWhite);return;}}}    }

If not from 0.01 then I have to select orders from 0.02 and so on. How do I write this point?

 
Rustam Bikbulatov minimal volume. My EA is currently selecting only orders with a volume of 0.01.

If not from 0.01 then I have to select orders from 0.02 and so on. How do I write this point?

if(OrderLots()==0.01)

You really do not see it yourself?

"How to check this point?" - you have to calculate the minimum value of the lot 0.01.

Perhaps, the slippage should be specified in points, i.e. 3*Point() and not 3

 
Rustam Bikbulatov minimal volume. My robot is currently selecting only orders with a volume of 0.01.

If not from 0.01 then I have to select orders from 0.02 and so on. How should this point be written?

You need 2 cycles: you should get the minimum volume in the first one and close it in the second one. And you should also take into account that when you close the orders, they are shifted by 1 position, so you should make a cycle from the maximum position to 0.
 
Andrey Sokolov #:

Do you really not see it yourself?

"How do I write this down?" - where it says 0.01 lot, you have to calculate the minimum available.

I can see that. If you set it to 0.02, the order with 0.02 lot will be selected. I asked how to set it to look at the 0.01 lot first, then at 0.02 and so on.

 
Sergey Gridnev #:
You need 2 cycles: you find out the minimum volume in the first one, and close it in the second one. And note that when you close the orders are shifted by 1 position, so you have to do the cycle from the maximum position to 0.

How do you go from maximum to 0 ?

 
Rustam Bikbulatov #:

I'm asking how to make it look first at 0.01, then 0.02 and so on.

You have already been told how twice.

 
Rustam Bikbulatov #:

I can see that. If you set it to 0.02, it will select orders with 0.02 lot. I'm asking how to set it to look at 0.01 first, then 0.02 and so on.

Collect in a two-dimensional array, the first dimension contains lots, the second ticket. Sort the array, and close while the first dimension has the smallest lot. Or if you need to close all, but as the lot increases, close until the end...

Reason: