Download MetaTrader 5
To add comments, please log in or register
Launch your trading signal and add account monitoring!
Thomas Schmidt
60
Thomas Schmidt 2013.10.21 20:22 

All,


My function has been failing due to order fulfilment issues, an order may not be fulfilled in one transaction, as per attached screen shot, relevant code is attached below.

In the above example, I should be reading a volume of 3.20 (0.5 + 2.70) and an out price of 1.61451 (1.61451+1.61451/2).

The question now is: How can I get my EA, list the complete order fulfilment, returning the sum of the volumes and the mean average of the price?

Thanks All

// Operation 001
// Get Last Deal Ticket Number

ulong GetLastDealTicket()
  {
   //--- Request history for the last 2 days
   if(!GetTradeHistory(2))
     {
      //--- notify on unsuccessful call and return -1
      Print(__FUNCTION__," HistorySelect() returned false");
      return -1;
     }
   //---
   ulong first_deal,last_deal,deals=HistoryOrdersTotal();
   //--- work with orders if there are any
   if(deals>0)
     {
      // Print("Deals = ",deals);
      first_deal=HistoryDealGetTicket(0);
      // PrintFormat("first_deal = %d",first_deal);
      if(deals>1)
        {
         last_deal=HistoryDealGetTicket((int)deals-1);
         // PrintFormat("last_deal = %d",last_deal);
         return last_deal;
        }
      return first_deal;
     }
   //--- no deal found, return -1
   return -1;
  }

// Operation 003
// Last Trade Results

void LastTradeResutls()
  {
   ulong last_deal=GetLastDealTicket();
   if(HistoryDealSelect(last_deal))
     {
      Core_ProfitLoss=HistoryDealGetDouble(last_deal,DEAL_PROFIT);
      Core_Volume=HistoryDealGetDouble(last_deal,DEAL_VOLUME);
      Print("Profit/Loss from last trade was: ",Core_ProfitLoss);
      Print("Volume from last trade was: ",Core_Volume);
    }
   else
      PrintFormat("HistoryDealSelect() failed for #%d. Eror code=%d",
                  last_deal,GetLastError());
  }

Files:
Simon Gniadkowski
Moderator
17994
Simon Gniadkowski 2013.10.23 13:23  
thomasschmidt:

All,


My function has been failing due to order fulfilment issues, an order may not be fulfilled in one transaction, as per attached screen shot, relevant code is attached below.

In the above example, I should be reading a volume of 3.20 (0.5 + 2.70) and an out price of 1.61451 (1.61451+1.61451/2).

The question now is: How can I get my EA, list the complete order fulfilment, returning the sum of the volumes and the mean average of the price?

Thanks All

<CODE REMOVED>

Please use the SRC button to post code: How to use the SRC button.
Alain Verleyen
Moderator
30299
Alain Verleyen 2013.10.23 14:07  
thomasschmidt:

All,


My function has been failing due to order fulfilment issues, an order may not be fulfilled in one transaction, as per attached screen shot, relevant code is attached below.

In the above example, I should be reading a volume of 3.20 (0.5 + 2.70) and an out price of 1.61451 (1.61451+1.61451/2).

The question now is: How can I get my EA, list the complete order fulfilment, returning the sum of the volumes and the mean average of the price?

Thanks All

Probably by using HistorySelectByPosition()
/
To add comments, please log in or register