How to get last state of a position?

 

I've written this piece of code on OnTradeTransaction event handler to know whether it is finished or not, but I don't get suitable result.

void OnTradeTransaction(const MqlTradeTransaction &trans,const MqlTradeRequest &request,const MqlTradeResult &result)
  {
   ENUM_TRADE_TRANSACTION_TYPE type=(ENUM_TRADE_TRANSACTION_TYPE)trans.type;
//--- if the transaction is the request handling result, only its name is displayed
   if(type==TRADE_TRANSACTION_ORDER_UPDATE)
     {
      if(trans.order_state==ORDER_STATE_FILLED)
        {
         // 
        }

     }

  }
 
amin_mohammadi:

I've written this piece of code on OnTradeTransaction event handler to know whether it is finished or not, but I don't get suitable result.

Your question is vague.

"to know whether it is finished or not" : What do  you want to know exactly ?

"I don't get suitable result" : Of course, your code do nothing. What result are you expecting ?

 
angevoyageur:

Your question is vague.

"to know whether it is finished or not" : What do  you want to know exactly ?

"I don't get suitable result" : Of course, your code do nothing. What result are you expecting ?

I want to know if it has met the T/P line and successfully finished
 
amin_mohammadi:
I want to know if it is moved from current orders to history list
Which "current orders", pending orders ? buy/sell orders ?
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 

And another question :D

How can I delete a file contents?

 
angevoyageur:
Which "current orders", pending orders ? buy/sell orders ?
yes, pending orders
 
amin_mohammadi:

And another question :D

How can I delete a file contents?

This one is clear at least. But you are off-topic, open an other one.
 
amin_mohammadi:
yes, pending orders
Ok, so you want to detect when your pending orders are triggered and  became buy/sell deals.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 
angevoyageur:
Ok, so you want to detect when your pending orders are triggered and  became buy/sell deals.
yes
Reason: