DealType is buy for Sell transaction

 

Hello Community or Support,

when i catch a sell order transaction for a simple Gold SELL MKT order, i get this transaction sequence:

QN      0       14:49:25.391    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_ORDER_ADD otype=ORDER_TYPE_SELL dtype=DEAL_TYPE_BUY
HF      0       14:49:25.396    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_ORDER_DELETE otype=ORDER_TYPE_SELL dtype=DEAL_TYPE_BUY
ID      0       14:49:25.397    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_HISTORY_ADD otype=ORDER_TYPE_SELL dtype=DEAL_TYPE_BUY
JM      0       14:49:25.398    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_DEAL_ADD otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_SELL
IO      0       14:49:25.398    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_REQUEST otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_BUY

So dealtype 

DEAL_TYPE_BUY


Here the transaction sequence for a Gold BUY MKT order:

NQ      0       14:52:19.177    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_ORDER_ADD otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_BUY
HI      0       14:52:19.184    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_ORDER_DELETE otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_BUY
CG      0       14:52:19.185    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_HISTORY_ADD otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_BUY
QF      0       14:52:19.187    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_DEAL_ADD otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_BUY
NL      0       14:52:19.189    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_REQUEST otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_BUY

So dealtype 

DEAL_TYPE_BUY

So for Sell orders it seems to be wrong, for buy orders it is correct. Seems to be asymmetrical.

Code:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }

string TransStr(const MqlTradeTransaction& t)
{
    
    string msg=StringFormat(" entry-type=%s trans-type=%s otype=%s dtype=%s"                                                            
                                                   ,EnumToString((ENUM_DEAL_ENTRY)HistoryDealGetInteger(t.deal,DEAL_ENTRY))                                          
                           ,EnumToString((ENUM_TRADE_TRANSACTION_TYPE) t.type)
                           ,EnumToString(t.order_type)
                           ,EnumToString(t.deal_type));
  
                        
    return msg;
}


//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
  {
//---
        Print(






TransStr(trans));
  } //+------------------------------------------------------------------+


Is this intended and if yes,  whats the logic behind?


2nd question:

What is the purpose of the last 2 transactions:

QF      0       14:52:19.187    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_DEAL_ADD otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_BUY
NL      0       14:52:19.189    otype_on_sell (GOLD,M1)  entry-type=DEAL_ENTRY_IN trans-type=TRADE_TRANSACTION_REQUEST otype=ORDER_TYPE_BUY dtype=DEAL_TYPE_BUY



Thank you

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM
  • www.mql5.com
Trade Orders in DOM - Trade Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5