Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

CpairedDealInfo Class - Library for MetaTrader 5 - MT4/MT5 Resources

author EAcpu | 5 reads | 0 comments |

CpairedDealInfo is a class used to reconstruct closed trades (paired in/out trades) based on history sorted by closing time.

This class has an interface similar to the standard library's CDealInfo class.

Class C Pairing Transaction Information: People Object { People :
                    C pairing transaction information ( blank );
                    ~CPairedDealInfo( blank );
//--- The method of accessing protected data is wrong. Invoicing ( blank ) constant { return (m_curr_ticket_in); }
Oolong ticket closing ( blank ) constant { return (m_curr_ticket_out); }
//--- Quick access method for integer transaction properties date time open time ( blank ) constant ;
Oolong time to open MSC( blank ) constant ;
datetime time off ( blank ) constant ;
Oolong time off MSC( blank ) constant ;
ENUM_DEAL_TYPE transaction type ( blank ) constant ;
string type description ( blank ) constant ;
long magic ( blank ) constant ;
Long position ID ( blank ) constant ;
long orderopen( blank ) constant ;
Long order closing ( blank ) constant ;
ENUM_DEAL_REASON open reason ( blank ) constant ;
ENUM_DEAL_REASON closing reason ( blank ) constant ;
//--- Quick access method for double transaction properties double volume ( blank ) constant ;
Double the opening price ( blank ) constant ;
Double stop loss ( blank ) constant ;
Double the take profit ( blank ) constant ;
Double price close( blank ) constant ;
double committee( blank ) constant ;
double exchange( blank ) constant ;
double profit( blank ) constant ;
//--- Quick access method for string transaction properties string symbol ( blank ) constant ;
string public comment( blank ) constant ;
string close comments( blank ) constant ;
string open reason description ( blank ) constant ;
string close reason description ( blank ) constant ;
//--- information method string format action( string &str, const unit action) constant ;
string formatreason( string &str, const unitreason ) constant ;
//--- Method for selecting transactions boolean history selection ( datetime start date, datetime so far);
integer All ( blank ) constants ;Boolean value selection by vote ( constant own vote); Boolean value selection by index ( constant integer index); };


Here is a sample code showing how to use this class in code

 #include //+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
blank start ()
  { //--- Variable to save paired transaction information CpairedDealInfo transaction; //--- Reconstruct transaction based on transaction history if (! Trade. History selection ( 0 , time current ()))
    {
alert ( "CPairedDealInfo::HistorySelect() failed!" );
return ;
    } //--- now process list of closed trades integer total = trade.Total();
for ( integer i = 0 ; i < total; i++)
    {
//--- Select a trade by its position in the list if (trade.SelectByIndex(i))
        {
Oolong Ticket_open = trade.TicketOpen();
Oolong Ticket_close = trade.TicketClose();
Date time time_open = trade.TimeOpen();
Mistake time_open_msc = trade.TimeOpenMsc();
Date time time_close = trade.TimeClose();
Mistake time_close_msc = trade.TimeCloseMsc();
long type = trade.DealType();
String type_desc = trade.TypeDescription();
long magic = trade.Magic();
Long pos_id = trade.PositionId();
long order_open = trade.OrderOpen();
long order_close = trade.OrderClose();
Double trading volume = trade.Volume();
Double Price_open = trade.PriceOpen();
Double Price_sl = trade.StopLoss();
Double Price_tp = trade.TakeProfit();
Double Price_close = trade.PriceClose();
Double commission = trade.Commission();
Double swap = trade.Swap();
Double profit = trade.Profit();
String symbol = trade. symbol ();
String open_comment = trade.OpenComment();
String close_comment = trade.CloseComment();
String open_reason_desc = trade.OpenReasonDescription();
String close_reason_desc = trade.CloseReasonDescription();
        }
    } //--- Print ( "Total number of closed transactions =" , Transaction.Total());
  } //+------------------------------------------------------------------+



Attachment download

📎 cpaireddealinfo.mqh (40.24 KB)

📎 demo_cpaireddealinfo.mq5 (4.66 KB)

📎 export_history_deals_v2.mq5 (16.56 KB)

Source: MQL5 #25200

Verification code Refresh