Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 783

 
Before EVERY close you have to. And changing the order of orders to reverse order helps.
 
evillive:
before EVERY closure is necessary.
Writing. The working condition of closing sells is missing. i.e. does not work at all...
 
in this form works in one way
 
how to reverse it?
 
-- MT4 hangs up
 
Leonid123456:
how do I reverse it?
for(int h=OrdersTotal()-1; h>=0; h--)
 

This is

 for(int b=0; b<OrdersTotal(); b++)
if(OrderSelect(b,SELECT_BY_POS)){
         
         lastlot = OrderLots();
              
         }

This is not the lot of the last trade, this is the lot of the last order, even pending and from a different symbol and from a different Expert Advisor or opened manually. Is that how it's supposed to be?

 
evillive:
for(int h=OrdersTotal()-1; h>=0; h--)

It's all working) Thank you. I've been wondering what's wrong. I've tried everything...

Thank you very much.

 
evillive:

This is

This is not the lot of the last deal, it is the lot of the first order you see, even pending and from a different symbol and from a different Expert Advisor or hand-opened. Is it designed that way?

It is the last order for this EA)) In general, it worked. It was the last one)). The Expert Advisor is for testing. So it works for several currencies and manual trading (together) is not envisaged yet.

Can you give me some tips for the future, it may be useful...

Thanks again.

 
Leonid123456:

for this EA last)). Actually, it worked. It was the last one)). This EA is for testing... So, work for several currencies and manual trading (together) is not envisaged yet...

Can you give me some tips for the future, it would be nice to know how to do it right...

Thanks again.

If you need it, you should distinguish a market order from a pending one. The first one you've come across, by all criteria (symbol, magician, type) is usually the freshest one. But it would be better to look at the time of opening as well so that it surely was not younger.

In the tester you may choose at once

OrderSelect(OrdersTotal()-1,SELECT_BY_POS))

to work with the last open order. If the system has no pending orders, everything will work fine. But if there are both pending and market orders, this will not work, not to mention the real work.

Reason: