Testing_Scripts/Tester_Generic.mq5
super.admin 48c5f07b6e convert
2025-05-30 16:30:20 +02:00

173 lines
6 KiB
MQL5

//+------------------------------------------------------------------+
//| Tester_Generic.mq5 |
//| Eduardo Zucarato |
//| zucarato@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Eduardo Zucarato"
#property link "zucarato@gmail.com"
#property version "1.00"
#property show_inputs
#include <Expert\Expert.mqh>
#include <Trade\DealInfo.mqh>
#include <Tools\DateTime.mqh>
class CMy_EA : public CExpert
{
protected:
string EA_Symbol;
public:
//Constructor
CMy_EA() { EA_Symbol=_Symbol; }
//Objects
CDealInfo deals;
CHistoryOrderInfo orders;
//Get-Set Methods
string GetSymbol() { return EA_Symbol; }
//CMy_EA() { }
};
// Global variables and objects
CMy_EA myea;
//+------------------------------------------------------------------+
//| Script initialization function |
//+------------------------------------------------------------------+
void OnStart()
{
// for ( int i=0 ; i<100000 ; i++ )
// {
// Print ("Iteration: ",i);
//myea.deals.Ticket(190253020);
CDateTime start;
// --- determining the time intervals of the required trading history
datetime end=TimeCurrent(); // current server time
//datetime start='' ;// set the beginning for 24 hours ago
start.DateTime(end);
start.Hour(0);
start.Min(0);
start.DayDec(2);
HistorySelect(start.DateTime(),end);
Print("Selection Start Time: ",start.DateTime());
Print("Selection End Time: ",end);
int mydealstotal = HistoryDealsTotal();
Print("Number of deals: ",mydealstotal);
Print("Number of orders in History: ",HistoryOrdersTotal());
for ( int i=0 ; i<mydealstotal ; i++ )
{
myea.deals.SelectByIndex(i);
Print("Profit of deal index no. ",i," and deal Ticket no. ",myea.deals.Ticket()," is = ",myea.deals.Profit());
myea.orders.Ticket(myea.deals.Order());
Print("Profit of order of deal index no. ",i," and deal Ticket no. ",myea.deals.Ticket()," order Ticket ",myea.orders.Ticket(),"is = ",myea.orders.TakeProfit());
}
/*
myea.deals.Ticket(138763154);
//Print("Profit of deal ticke no.: ",myea.deals.Ticket()," is: ",myea.deals.Profit());
Print("Profit of deal ticke no.: ",myea.deals.Ticket()," is: ",myea.deals.Profit());
Print("PositionID of deal ticke no.: ",myea.deals.Ticket()," is: ",myea.deals.PositionId());
Print("Order ticker of deal ticke no.: ",myea.deals.Ticket()," is: ",myea.deals.Order());
if ( )
{
Print("Deal selected correctly");
}
else
{
Print("Deal selection failure");
}
*/
// }
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
myea.History.f6030CalculateCurrentCloseResult();
Print("Number of deals is: ",HistoryDealsTotal());
Print("Current closed result is: ",myea.History.GetCurrentClosedResult());
/*
int mydealstotal = HistoryDealsTotal();
Print("Number of deals for selected period: ",mydealstotal);
for ( int i=0 ; i<mydealstotal ; i++ )
{
myea.Deals.SelectByIndex(i);
Print("Profit of deal index no. ",i," and deal Ticket no. ",myea.Deals.Ticket()," is = ",myea.Deals.Profit());
myea.Orders.Ticket(myea.Deals.Order());
Print("Profit of order of deal index no. ",i," and deal Ticket no. ",myea.Deals.Ticket()," order Ticket ",myea.Orders.Ticket(),"is = ",myea.Orders.TakeProfit());
}
/*
myea.deals.Ticket(138763154);
//Print("Profit of deal ticke no.: ",myea.deals.Ticket()," is: ",myea.deals.Profit());
Print("Profit of deal ticke no.: ",myea.deals.Ticket()," is: ",myea.deals.Profit());
Print("PositionID of deal ticke no.: ",myea.deals.Ticket()," is: ",myea.deals.PositionId());
Print("Order ticker of deal ticke no.: ",myea.deals.Ticket()," is: ",myea.deals.Order());
if ( )
{
Print("Deal selected correctly");
}
else
{
Print("Deal selection failure");
}
*/
// }
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Expert Deal function |
//+------------------------------------------------------------------+
void OnDeal()
{
//---
Print("");
}
//+------------------------------------------------------------------+