MQL5 - How to check if Position/Order closed in EA - page 2

 
Alain Verleyen:

Don't use confusing variable name, your 'Ticket' variable is not a position ticket, it's a CTrade object.

Please post your code if you need coding help, what you are asking for is pretty trivial.

Dear Alain,


Thanks again for your help. i will try to send my code night time as currently i don't have access (I'm in somewhere else)

Last night i could manage to create some functions for control this. But as i didn't have time, i couldn't test this to inform you the result


There is one question stays in my mind which is :"What is Ticket main number to be used in PositionSelectByTicket() ? Is it Deal Ticket Number or Order Ticket Number?" in ordersend() result object, you may find both

 
ArashB:

Dear Alain,


Thanks again for your help. i will try to send my code night time as currently i don't have access (I'm in somewhere else)

Last night i could manage to create some functions for control this. But as i didn't have time, i couldn't test this to inform you the result


There is one question stays in my mind which is :"What is Ticket main number to be used in PositionSelectByTicket() ? Is it Deal Ticket Number or Order Ticket Number?" in ordersend() result object, you may find both

It's position ticket, which is the order ticket when you open a new position.
 
appreciate
Alain Verleyen:
It's position ticket, which is the order ticket when you open a new position.

Thanks a lot.

I've developed an EA but as i couldn't get any result of running yet i should put some more time on it.

I will try to share my results by tonight. to have a wrap up on this subject for future readers

 

Final Result


1. To control a trade (check if it is closed or not) concept is totally different and you may put your code inside OnTrade which handle all trade opening/closing events.

    if you want to control the order changes (modify) you may use OnTradeTransaction

2. As I controlled CTrade and Deal, in all of their classes using the new format to control position. all positions works based on original OrderSend() which is very different from MT4

    But by study a bit and understanding it, you may create simple function by your own like OrderSendMQL4(.....) to match them

3. As I understand there is no close on MQL5 at all and for closing a position you have to order send the same amount in opposite direction.

4. For managing the tickets you have to use HistorySelect() and HistoryDeal...()


As i'm not fully sure for all above items, I'm Open to hear from other expert members in forum if my understanding is wrong

 

Dears,


i faced another strange issue. i got error during sending order according below :

Unsupported filling mode


i read and i know i should control the filling_type according below. but it doesn't work

request.type_filling = SymbolInfoInteger(symbol,SYMBOL_FILLING_MODE);


did you ever experienced such issue before?

 
ArashB:

Dears,


i faced another strange issue. i got error during sending order according below :

Unsupported filling mode


i read and i know i should control the filling_type according below. but it doesn't work


did you ever experienced such issue before?

i figured this out.


it was related to broker itself. i changed original MetaTrader to MT5 of one Broker and it works properly

Reason: