CTrader.Buy() e OnTradeTransaction()

 

Olá pessoal

Minha dúvida é referente ao retorno do numero da deal e order na OnTradeTransaction() em contas HEDGE

Estou usando para realizar operações a biblioteca CTrader

 

Bom vamos lá. Neste exemplo o Expert entra COMPRADO , eu verifico o retorno do código  e apresento  ele no log como podem ver a baixo

   int trycath = 1;
   while(true)
     {
      if(trycath == limitTryedSendOrder)
         break;
      bool returnedTrade = trade.Buy(lots, _Symbol,0, stoploss, takeprofit,comment);
      ulong retCode = trade.ResultRetcode();
      if(!(retCode == TRADE_RETCODE_PLACED || retCode == TRADE_RETCODE_DONE))
        {
         int errorCode = GetLastError();
         Print("lots    "+lots+"   BuyMarket : "+errorCode+"         |        ResultRetcode :  "+retCode);
         ResetLastError();
         trycath++;
         Sleep(150);
        }
      else
        {
         order = trade.ResultOrder();
         deal = trade.ResultDeal();
         break;
        }
     }
   Print("\n===== A MERDADO COMPRA | RESULT RET CODE :  "+trade.ResultRetcode());
   Print("LOTE ENVIADO  :  "+lots);
   Print("TKT DEAL : "+deal);
   Print("TKT OFERTA : "+order);

print


Reparem no numero de deal order retornados no meu log...

Se a gente olhar o log que da OnTradeTransaction() , vamos notar que curiosamente o numero de Orders e Deals que é usado como  referencia a transação da ordem em todas as suas etapas de evento, são diferentes das retornadas logo após a solicitação da ordem ( trade.ResultOrder() e trade.ResultDeal()) .

A única coisa que bate nos logs da OnTradeTransaction() é o número magico .

O numero que a OnTradeTransaction() me retorna é:
Deals -1280893669

Order - 1280342342

Outro fato curioso é que o numero da Order e Deals esta retornando negativamente.

Por que isso acontece ?

Em Netting esses problemas nunca apareceram para mim!
alguém pode me dar uma ajuda? Obrigado a todos desde já.

Documentação sobre MQL5: Manipulação de eventos / OnTradeTransaction
Documentação sobre MQL5: Manipulação de eventos / OnTradeTransaction
  • www.mql5.com
OnTradeTransaction - Manipulação de eventos - Referência MQL5 - Referência sobre algorítimo/automatização de negociação na linguagem para MetaTrader 5
 
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Transaction===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the deal: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      position : 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the deal: DEAL_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Status of the order: ORDER_STATE_STARTED
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Stop Loss: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Take Profit: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price that triggers the Stop Limit order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Trade symbol: 
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pending order expiration time: 1970.01.01 00:00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration type: ORDER_TIME_GTC
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the trade transaction: TRADE_TRANSACTION_REQUEST
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume in lots: 0.00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Request===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the trade operation: TRADE_ACTION_DEAL
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Comment to the order: 
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      position : 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Deviation from the requested price: 10
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration time: 1970.01.01 00:00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Magic number of the EA: 12345
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price: 0.99808
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Stop Loss level of the order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Take Profit level of the order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      StopLimit level of the order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Trade symbol: EURUSD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order execution type: ORDER_FILLING_FOK
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration type: ORDER_TIME_GTC
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume in lots: 0.71
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Result===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Code of the operation result: 10021
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the deal: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume of the deal: 0.00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price of the deal: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Bid: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ask: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Comment to the operation: 
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Request ID: 106
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pass : #1
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Request received: place a market order
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Transaction===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the deal: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      position : 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the deal: DEAL_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: -1280342342
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Status of the order: ORDER_STATE_STARTED
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price: 0.99809
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Stop Loss: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Take Profit: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price that triggers the Stop Limit order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Trade symbol: EURUSD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pending order expiration time: 1970.01.01 00:00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration type: ORDER_TIME_GTC
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the trade transaction: TRADE_TRANSACTION_ORDER_ADD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume in lots: 0.71
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pass : #1
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Open a new market order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Transaction===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the deal: -1280893669
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      position : 50259265210
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the deal: DEAL_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: -1280342342
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Status of the order: ORDER_STATE_STARTED
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price: 0.99809
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Stop Loss: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Take Profit: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price that triggers the Stop Limit order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Trade symbol: EURUSD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pending order expiration time: 1970.01.01 00:00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration type: ORDER_TIME_GTC
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the trade transaction: TRADE_TRANSACTION_DEAL_ADD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume in lots: 0.71
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pass : #1
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Deal added to history: #-1280893669, DEAL_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      EURUSD: new position opened
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ====== Abertura de uma ordem a mercado
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ==== RETORNO COMPRA
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      DEAL    -1280893669
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      order      -1280342342
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      lote    0.71
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Transaction===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the deal: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      position : 50259265210
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the deal: DEAL_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: -1280342342
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Status of the order: ORDER_STATE_FILLED
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price: 0.99809
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Stop Loss: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Take Profit: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price that triggers the Stop Limit order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Trade symbol: EURUSD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pending order expiration time: 1970.01.01 00:00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration type: ORDER_TIME_GTC
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the trade transaction: TRADE_TRANSACTION_ORDER_DELETE
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume in lots: 0.00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pass : #1
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Deleted from the list of open orders: #-1280342342, ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Transaction===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the deal: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      position : 50259265210
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the deal: DEAL_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: -1280342342
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Status of the order: ORDER_STATE_FILLED
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price: 0.99809
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Stop Loss: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Take Profit: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price that triggers the Stop Limit order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Trade symbol: EURUSD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pending order expiration time: 1970.01.01 00:00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration type: ORDER_TIME_GTC
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the trade transaction: TRADE_TRANSACTION_HISTORY_ADD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume in lots: 0.00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pass : #1
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order added to the history: #-1280342342, ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Transaction===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the deal: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      position : 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the deal: DEAL_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Status of the order: ORDER_STATE_STARTED
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Stop Loss: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Level of Take Profit: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price that triggers the Stop Limit order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Trade symbol: 
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pending order expiration time: 1970.01.01 00:00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration type: ORDER_TIME_GTC
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the trade transaction: TRADE_TRANSACTION_REQUEST
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume in lots: 0.00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Request===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the trade operation: TRADE_ACTION_DEAL
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Comment to the order: 
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      position : 0
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Deviation from the requested price: 10
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration time: 1970.01.01 00:00
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Magic number of the EA: 12345
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: -1280342342
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price: 0.99809
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Stop Loss level of the order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Take Profit level of the order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      StopLimit level of the order: 0.00000
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Trade symbol: EURUSD
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Type of the order: ORDER_TYPE_BUY
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order execution type: ORDER_FILLING_FOK
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Order expiration type: ORDER_TIME_GTC
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume in lots: 0.71
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      ---===Result===---
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Code of the operation result: 10009
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the deal: -1280893669
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ticket of the order: -1280342342
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Volume of the deal: 0.71
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Price of the deal: 0.99809
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Bid: 0.99809
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Ask: 0.99809
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Comment to the operation: 
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Request ID: 107
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Pass : #1
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      Request received: place a market order
CS      0       14:04:08.638    RDS_BOT(EURUSD,M1)      
 

Tópico em duplicidade:

Fórum de negociação, sistemas de negociação automatizados e testes de estratégias de negociação

Ajuda CTrader.Buy() e OnTradeTransaction()

Vinicius de Oliveira, 2022.10.28 14:01



Bom dia!!


Se você observar, o valor de ResultOrder() corresponde ao valor de POSITION no OnTradeTransaction:


Essas informações não seriam suficientes pra atender aí às suas expectativas?


. . .


 
Vinicius de Oliveira #:

Tópico em duplicidade:


Com certeza resolve me basear pelo position. 

Minha dúvida é mais para entender por que a order e deal retorna negativamente? ja aconteceu isso com você ?

Um fato curioso é que isso aconteceu com a corretora MetaQuotes (a que vem default quando voce instala o mt5 direto do site)

Eu fiz o mesmo teste em outra corretora HEDGE e não deu mais este problema.


Qual a forma correta de fazer esses tratamentos de retorno | envio | retirada | atualização de ordens e deals...   ?

é correto eu sempre me basear pelo retorno da ontradetransaction?

ou é comum as pessoas tratarem  dentro do fluxo da OnTick?

Minha opinião : nao me parece correto tratar o retorno das ordens e deal enviadas dentro da OnTick. Entendo que a OnTradeTransaction funciona através de evento e que por padrão ela vem de forma assíncrona . No meu caso eu defini trade.SetAsyncMode(false) para deixar ele síncrono . Com isso tenho a esperança de sempre ter a garantia do retorno dos eventos. 

 
Igor Andre Mello Da Silva #:

Com certeza resolve me basear pelo position. 

Minha dúvida é mais para entender por que a order e deal retorna negativamente? ja aconteceu isso com você ?

Um fato curioso é que isso aconteceu com a corretora MetaQuotes (a que vem default quando voce instala o mt5 direto do site)

Eu fiz o mesmo teste em outra corretora HEDGE e não deu mais este problema.


Qual a forma correta de fazer esses tratamentos de retorno | envio | retirada | atualização de ordens e deals...   ?

é correto eu sempre me basear pelo retorno da ontradetransaction?

ou é comum as pessoas tratarem  dentro do fluxo da OnTick?

Minha opinião : nao me parece correto tratar o retorno das ordens e deal enviadas dentro da OnTick. Entendo que a OnTradeTransaction funciona através de evento e que por padrão ela vem de forma assíncrona . No meu caso eu defini trade.SetAsyncMode(false) para deixar ele síncrono . Com isso tenho a esperança de sempre ter a garantia do retorno dos eventos. 

Oi Igor. Tenho visto o pessoal comentar que o OnTradeTransaction não garante a execução. Também, a ordem da leitura pode mudar...

O que temos na documentação é:

O comprimento da fila de transações é de 1 024 itens. Se a OnTradeTransaction() demorar a processar a seguinte transação muito tempo, as transações anteriores na fila poderão ser substituídas por transações mais recentes.

Eentendo que se tiver muitas (muitas mesmo) operações ao mesmo tempo ou uma lentidão de processamento, você pode perder a leitura de alguns dados.

Razão: