Fetching the execution price from a limit order

 
Hey guys,

I've tried multiple ways to fetch the execution price from a limit order in demo mode, but all of them failed.

Here's my code:

#include <Trade\Trade.mqh>

CTrade tradeLong;

int OnInit()
  {
  tradeLong.BuyLimit(0.01, NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits), NULL, 0, 0, ORDER_TIME_GTC, 0, "");
  return(INIT_SUCCEEDED);
  }

void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
  {
  if(trans.type == 6)//TRADE_TRANSACTION_DEAL_DELETE
    {
    Print("trans.type: ", trans.type);
    Print("trans.deal: ",trans.deal);
    Print("trans.price: ", trans.price);//<-- returns limit price
    Print("request.price: ", request.price);//<-- returns 0.0
    Print("result.price: ", result.price);//<-- returns 0.0
    Print("tradeLong.ResultPrice(): ", tradeLong.ResultPrice());//<-- returns 0.0
    }
  }

Can someone please explain what I'm doing wrong here?


Thanks!

 
virtualreal:
Hey guys,

I've tried multiple ways to fetch the execution price from a limit order in demo mode, but all of them failed.

Here's my code:

Can someone please explain what I'm doing wrong here?


Thanks!


You can use

Documentation on MQL5: Trade Functions / PositionGetDouble
Documentation on MQL5: Trade Functions / PositionGetDouble
  • www.mql5.com
PositionGetDouble - Trade Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Much appreciated, thanks for your suggestion.
This website uses cookies. Learn more about our Cookies Policy.