Deals

 

I've played around with the the various Deal-related functions in MQL5 (HistoryDealSelect, HistoryDealsTotal, HistoryDealGetTicket, HistoryDealGetDouble, HistoryDealGetInteger, HistoryDealGetString) and I'm wondering if they apply at all to Forex?  I can't find any scenario where HistoryDealsTotal() > 0

Paul

http://paulsfxrandomwalk.blogspot.com/ 

Regularly emailing the status of an account
  • 2012.06.14
  • Paul
  • paulsfxrandomwalk.blogspot.com
Prompted by a query, I thought I'd post a useful little utility that I have used for ages which emails the status of the account every hour.  After lengthy deliberation I decided to call it .... EmailStatus.  With only a small modification it could be used to log the status to a file, and the time...
 
Try this sample
//+------------------------------------------------------------------+
//|                                                 Test_OnTrade.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
#property version   "1.00"


//+------------------------------------------------------------------+
//|  обработка события Trade                                         |
//+------------------------------------------------------------------+
void OnTrade()
  {
   static int posTotals=-1;
   static int ordTotals=-1;
   static int histOrders=-1;
   static int histDeals=-1;
   datetime trade_time=TimeCurrent();
//---
   datetime from_date=0;//TimeCurrent()-PeriodSeconds(PERIOD_MN1);
   datetime to_date=TimeTradeServer();
   HistorySelect(from_date,to_date);
   Print("Requested history from "+
         TimeToString(from_date)+" to "+
         TimeToString(to_date));
//--- first time calling
   if(posTotals==-1)
     {
      posTotals=PositionsTotal();
      ordTotals=OrdersTotal();
      histOrders=HistoryOrdersTotal();
      histDeals=HistoryDealsTotal();
      Print(__FUNCTION__,":List of orders, deals and positions wereinitialized");
     }
   else
     {
      int currOrders=OrdersTotal();
      int currPositions=PositionsTotal();
      int currHistDeals=HistoryDealsTotal();
      int currHistOrders=HistoryOrdersTotal();
      //--- check orders
      if(currOrders!=ordTotals)
        {
         ordTotals=currOrders;
         Print("Pending orders list was changed");
        }
      //--- check open positions
      if(currPositions!=posTotals)
        {
         posTotals=currPositions;
         Print("Open positions list was changed");
        }
      //--- check ordersin history
      if(currHistOrders!=histOrders)
        {
         histOrders=currHistOrders;
         Print("History orders list was changed");
        }
      //--- check history of deals
      if(currHistDeals!=histDeals)
        {
         Print("Deals history changed");
         Print("before:histDeals =",histDeals,"  currHistDeals =",currHistDeals);
         histDeals=currHistDeals;
         //Print("after:histDeals =",histDeals,"  currHistDeals =",currHistDeals);

        }
     }

  }
//+------------------------------------------------------------------+

 
Rosh:
Try this sample

Thanks Rosh, I now think I understand how Deals work