My EA does a double entry - page 10

 
angevoyageur: Not sure I understand what you mean. This issue we are talking in this topic is not caused by a bad coding but by a bad design in mql5 (it's my opinion, or maybe it's simply a bug ?). What do you mean by "multiple trading thread" ? 

I went back and re-read what you consider bad-design.

Within old-mt4 these class do-not exist. The normal method of checking for Successful_Orders within is Ticket#==(-1) && GetLastError(). I've never seen a case where your order returns a valid ticket# and GLE=0. But upon the next tick, your OrdersTotal() still returns 0.

Now keep in mind I haven't been through the entire mql5 documentations. However, if it says that PositionSelect_Information doesn't get updated until later. And someone is using PositionSelect to evaluate their entry logic. Then that person must wait until PositionSelect_Information is updated before exiting the OrderSend Logic. 

For the thread thing... I was talking about multiple threads vs single treaded for sending orders. As in simultaneous orders opening at the same time. It may or may not be relevant here.

 
Ubzen:

I went back and re-read what you consider bad-design.

Within old-mt4 these class do-not exist. The normal method of checking for Successful_Orders within is Ticket#==(-1) && GetLastError(). I've never seen a case where your order returns a valid ticket# and GLE=0. But upon the next tick, your OrdersTotal() still returns 0.

Now keep in mind I haven't been through the entire mql5 documentations. However, if it says that PositionSelect_Information doesn't get updated until later. And someone is using PositionSelect to evaluate their entry logic. Then that person must wait until PositionSelect_Information is updated before exiting the OrderSend Logic. 

For the thread thing... I was talking about multiple threads vs single treaded for sending orders. As in simultaneous orders opening at the same time. It may or may not be relevant here.

The documentation about PositionSelect doesn't said anything about "doesn't get updated until later". It only said the even if PositionSelect is true, the information about a Position can be outdated, which is not related to your issue here.

I'll take the time to do some tests when the market is opened to be sure not to say anything stupid, more complete answer later.

 
angevoyageur:

The documentation about PositionSelect doesn't said anything about "doesn't get updated until later". It only said the even if PositionSelect is true, the information about a Position can be outdated, which is not related to your issue here.

I'll take the time to do some tests when the market is opened to be sure not to say anything stupid, more complete answer later.

K..... and btw, if the document doesn't say anything then I totally agree with you.

The question we're going to be asking the Service_Desk ultimately is "why can't you update the Position_Information when trade.PositionOpen()==true?"

They'll probably have a good answer for us

 
angevoyageur:

No. I was just thinking about that...It would be probably useful if all concerned people write a ticket to ServiceDesk about this issue. However I am very sceptical if MQ is willing to change this design. But we can try.

People can write to ServiceDesk and report the ticket# here. Mine is 

Errors, MetaTrader 5 MQL, Open, Start: 2013.12.23 19:08, #916435


I have also informed the service desk, #933192 | 2014.01.19 14:44

 

MQ actually can easily redesign this to have a timeout function?

Like no response then we will get an error, something like that? 

 
doshur:

MQ actually can easily redesign this to have a timeout function?

Like no response then we will get an error, something like that? 


They made exactly the inverse. When mql5 was created there was a timeout parameter for function like PositionSelect.

But they remove it later, see point 9 here https://www.mql5.com/en/forum/53/page5#comment_14479

 

I agree with the arguments of a bad design, but in my opinion the main problem with MQL5 was to adapt a succesful Forex based code to work as such with stock markets (what is really a great stuff).

For instance, several stock markets use FIX protocol as a standard, and for me this communication protocol is not easy to adapt any code or architecture.

Anyway, I believe MQ guys had a time challenge, and had to create MQL5 based on MQL4, and not from scratch. I remember that Championship at that year was suspended to they have more time.

So, maybe this topic can be a great advice for future MQL6 and to a really new architecture from scratch, mainly regarding transactions resilience and agnostic solutions to work in any market.

 
doshur:

MQ actually can easily redesign this to have a timeout function?

Like no response then we will get an error, something like that? 

Traditionally, TimeOut doesn't mean that the order is-not going to become a position. You'll have to wait for a prolong period of time .. checking if it does become a position ... and end up suspending trading should the order not get executed.

I think MQ would side with figurelli about this being a programmer's error. Because the functions which the trade.PositionOpen is built upon clearly states that you need to check other things.


****** (Adding personal Agenda ... you may stop reading at this point) *******

This is the reason I do-not hound new-programmers about Function and their Return Values when helping them on mql_forum. I see no point in saying always do the following.

if( OrderSend()<0 ) { Print( GetLastError() ); }

This is suppose to be an automated trader ... you could be away ... and what it does is Print()?

In my mind, Error_Handling and Error_Reporting are 2_very different monsters. Trying to explain the proper ways of Handling an Error could take pages and is very personal to the Trader how many times they should re-try or even if they should terminate trading.

**** Now I'm not saying if a newbie is coding an EA and it has problems Trading ... That they shouldn't Print( GetLastError(); ) <- This should be obvious. But if I'm gonna tell them to always Get_Error, then I should also be telling them to always Handle_Error. *** End of Agenda. ****

 
angevoyageur:


They made exactly the inverse. When mql5 was created there was a timeout parameter for function like PositionSelect.

But they remove it later, see point 9 here https://www.mql5.com/en/forum/53/page5#comment_14479

Time to revive it?
 
doshur:
Time to revive it?

I don't think so. A synchronous trading request have to be synchronous in all the aspects. It's as simple as that.

Here the request is synchronous but then you have to manage asynchronous stuff. And nothing is documented about that.

Reason: