Files
MT5-EA-Sniper-Strategy/Include/A_HistoryChecker.mqh
T
2021-11-14 05:50:50 +01:00

60 lines
4.6 KiB
Plaintext

//+------------------------------------------------------------------+
//| A_HistoryChecker.mqh |
//| Copyright 2021, Nkondog Anselme Venceslas |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Nkondog Anselme Venceslas"
#property link "https://www.mql5.com"
void CheckHistory()
{
ulong ticket=0;
double profit;
datetime time;
string symbol;
long type;
long entry;
datetime timeStart = TimeCurrent() - PeriodSeconds(PERIOD_D1);
HistorySelect(timeStart,TimeCurrent());
uint total=HistoryDealsTotal();
//lotMultiplier = 1;
Print("Total deal in history ", total);
lotMultiplier = 1.0;
for(uint i=0; i<total; i++)
{
//--- essaye de récuperer le ticket des transactions
if((ticket=HistoryDealGetTicket(i))>0)
{
//--- récupère les propriétés des transactions
time =(datetime)HistoryDealGetInteger(ticket,DEAL_TIME);
symbol=HistoryDealGetString(ticket,DEAL_SYMBOL);
type =HistoryDealGetInteger(ticket,DEAL_TYPE);
entry =HistoryDealGetInteger(ticket,DEAL_ENTRY);
profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
//--- seulement pour le symbole courant
//Print("Ticket ", ticket," Time ", TimeToString(time, TIME_MINUTES));
if(type == DEAL_TYPE_BUY || type == DEAL_TYPE_SELL && profit != 0.0)
{
lt.time = TimeToString(time, TIME_DATE);
lt.type = IntegerToString(type);
lt.profit = profit;
Print("--- Today history --> Ticket ", ticket, " heure ", TimeToString(time, TIME_DATE), " Symbol ", symbol, " type ", type, " entree ", entry, " profit ", profit);
if(profit < 0)
{
lotMultiplier *= 2.0;
Print("Ajout multiplier ", lotMultiplier);
}
if(profit > 0)
{
lotMultiplier = 1.0;
Print("Rest multiplier ", lotMultiplier);
}
}
}
}
}
//+------------------------------------------------------------------+