MT5 and speed in action - page 6

 
A100:

It is suggested that you return repeatedly until you either read the entire current queue or for a given number of events. When the trade events are over, there will be a timer return and you will have access to all events at once

Well, I'm going to say something... Of course, of course, IMHO, but it's asking to run handler in a separate thread. So, just thinking out loud...

And if you are doing it for yourself, you put everything outside and every handler will be something similar:

void OnXXX{
 gOnXXXMutex.Lock();
 COnXXXOverlapped overlapped=new COnXXXOverlapped(<param_list>);
 gOnXXXOverlappedList.PushBack(overlapped);
 gOnXXXMutex.Unlock();
 DLLOnXXX(<param_list>,overlapped,&gOnXXXMutex);
}
 
A100:
there is a more elegant solution, without OnTimer... think about it

Think for yourself why it wouldn't work.

 
fxsaber:

Think for yourself why it wouldn't work.

And there's no need to think - the market has just opened, I checked - everything works, until the calculation of the line

if (наблюдаемая позиция закрылась по тейку)

trade events have been added to the queue and can be read

 
A100:

And here you don't need to think - the market has just opened, I checked - everything works, up to the line

trade events have been added to the queue and can be read

Sorry, but I won't even explain anything in your understanding of proper operation. Tired of having to spell out simple things.

 
fxsaber:

I'm sorry, but I won't even explain anything in your understanding of proper operation. I'm tired of having to explain simple things.

If you don't want to explain it, don't explain it. I just showed you that adding

bool HandleNextEvent (ENUM_EVENT_TYPE);

doesn't fundamentally change anything

 
A100:

does not fundamentally change

It makes a big difference. It just seems to take a lot of time (with an unknown result) to make the idea obvious in many heads.

 
fxsaber:

It makes a big difference. It just seems to take a lot of time(with unknown result) to make this idea obvious in many heads.

Not a lot, because according to Einstein's Theory of Simplicity: "If you can't explain it simply, you don't understand it yourself".

 
A100:

You don't have to, because according to Einstein's Theory of Simplicity: "If you can't explain it simply, then you don't understand it all the way yourself."

Yeah, you didn't get it.

 
fxsaber:

Yes, it didn't work for you.

And I didn't try to explain anything - I gave an example and got results:

Forum on trading, automated trading systems and strategy testing

MT5 and Speed in Action

A100, 2020.05.31 23:23

...market just opened, I checked - everything is working, before the calculation of the line

if (наблюдаемая позиция закрылась по тейку)

trading events were added to the queue and can be read

It turns out that you can read trade events from OnMain(). You claimed otherwise
 
A100:

I didn't try to explain anything - I gave an example and got the result:

It turned out that you can read trade events from OnMain(). You claimed the contrary.

You have not understood anything. When we do return, we are entering the On-function of the queue formed. It may cause a pause which prevents sending the correct second one immediately after the first OrderSend.

You propose to accumulate the queue by saving all On-functions after return, waiting for the On-function, in which there will be a message about end of the first OrderSend. And then only send the second OrderSend.

At the same time you don't understand that the take position can be executed during the first OrderSend, but its OnTradeTransaction will be in the queue later (in the same microsecond, but later) than the finishing OnTradeTransaction from the first OrderSend.

Reason: