From theory to practice - page 227

 
Maxim Dmitrievsky:

because you have to check the result of the trade execution first, and then check the order total

The author has several identical EAs working asynchronously, each on the chart of its own pair and, apparently, not communicating with each other. Therefore, it may happen that one EA has sent an order to open a position and the response has not come yet, i.e., the position has not opened yet (OrdersTotal()==0). Then another EA (maybe more than one) also sends a trade request, and as a result, 2 or more positions open at once. The idea is that in order to avoid such overlaps, we should set a flag ( a global variable of the terminal) and read it when sending the 1st trade order by other Expert Advisors.

But such situations can occur quite frequently, especially on news when many pairs make sharp jumps almost synchronously.

 
Alexander Sevastyanov:

The author has several EAs of the same type, each one is on the chart of its own pair, and apparently, they do not communicate with each other. Therefore, there may be times when one EA has sent a trade order to open a position and the order is under processing or the response has not come yet, i.e., the position has not opened yet (OrdersTotal()==0). Then another EA (and maybe more than one) also sends a trade request, and as a result, 2 or more positions open at once. The idea is that in order to avoid such overlaps, we should set a flag ( a global variable of the terminal) and read it when sending the 1st trade order by other Expert Advisors.

These situations may happen again, especially on news when many pairs are making sharp jumps.

I didn't see it specified that there should be only 1 trade at a time, I thought there should be several openings for 1 symbol

 
Alexander Sevastyanov:

The author has several EAs of the same type, each one is on the chart of its own pair, and apparently, they do not communicate with each other. Therefore, there may be times when one EA has sent a trade order to open a position and the order is under processing or the response has not come yet, i.e., the position has not opened yet (OrdersTotal()==0). Then another EA (and maybe more than one) also sends a trade request, and as a result, 2 or more positions open at once. The idea is that in order to avoid such problems, we should set a flag ( a global variable of the terminal) and read it when sending the 1st trade order by other Expert Advisors.

That's exactly what it is, Alexander.

I am now carefully reading the branch and all recommendations for fixing this problem. Because I'm terrified of what will happen if trades open at once on all 32 pairs... Of course, it shouldn't be like that.

 
Alexander_K2:

...reading the thread now and all the recommendations for fixing this problem. For I dread to think what will happen if trades open on all 32 pairs at once... Of course, it shouldn't be like that.

If you need any help - feel free to contact me.

By the way, the delay in opening a position is mainly made up of double ping (round trip) and the processing time of the trade order by the server. Good brokers that do not overload real servers and have a good communication channel with liquidity providers have processing time of trade orders of units of milliseconds. Ping can be significantly reduced from hundreds of milliseconds to units by hosting the Expert Advisor on a VPS server. You can see the total time taken to send a trade order, process it and get a response from the server in the MT4 log.

 
Alexander Sevastyanov:

If you need any help, please do not hesitate to contact us.

Oh, by the way, the delay in opening a position is mainly made up of double ping (round-trip) and server processing time. Good brokers that do not overload real servers and have a good connection channel with liquidity providers have processing time of trade orders of units of milliseconds. Ping can be significantly reduced from hundreds of milliseconds to units by hosting the Expert Advisor on a VPS server. You can see the total time taken to send a trade order, process it and get a response from the server in the MT4 log.

there are no such brokers in forex, tens of milliseconds minimum, average 200, at zero pings

 
Maxim Dmitrievsky:

I didn't see it specified that there should only be 1 trade at a time, I thought there were several openings for 1 instrument

This bug may occur even in one symbol if the previous thread hasn't finished execution and a new tick has come - then there is an undefined situation of reading and writing of actual data...
 
Andrei:
This bug may well occur even for a single tool if the previous thread hasn't finished execution and a new tick comes - then there is an undefined situation of writing and reading actual data...

No, there is no such a situation, it skips ticks until all logic is processed

 
Maxim Dmitrievsky:

No, there are no such situations, the ontic skips ticks until all the logic is processed

That's what I thought too...

 
Andrei:

I was thinking the same thing...

I don't know, never happened, traded with a bunch of scalping brokers on mt4 and mt5

 
Maxim Dmitrievsky:

I don't know, never have, traded with a bunch of scalping brokers on mt4 and mt5

How did you check? I only checked on mt4...
Reason: