Download MetaTrader 5

How to get last state of a position?

To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
amin_mohammadi
88
amin_mohammadi 2013.12.04 08:00 

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)
        {
         // 
        }

     }

  }
Alain Verleyen
Moderator
30744
Alain Verleyen 2013.12.04 09:10  
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 ?

amin_mohammadi
88
amin_mohammadi 2013.12.04 09:15  
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
Alain Verleyen
Moderator
30744
Alain Verleyen 2013.12.04 09:18  
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
amin_mohammadi
88
amin_mohammadi 2013.12.04 09:18  

And another question :D

How can I delete a file contents?

amin_mohammadi
88
amin_mohammadi 2013.12.04 09:19  
angevoyageur:
Which "current orders", pending orders ? buy/sell orders ?
yes, pending orders
Alain Verleyen
Moderator
30744
Alain Verleyen 2013.12.04 09:20  
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.
Alain Verleyen
Moderator
30744
Alain Verleyen 2013.12.04 09:22  
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
amin_mohammadi
88
amin_mohammadi 2013.12.04 09:25  
angevoyageur:
Ok, so you want to detect when your pending orders are triggered and  became buy/sell deals.
yes
To add comments, please log in or register