double DailyProfit()
{
double profit = 0;
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==TRUE)
{
if(OrderType()>1) continue;
if(TimeToStr(TimeCurrent(),TIME_DATE) == TimeToStr(OrderCloseTime(),TIME_DATE))
{
profit += OrderProfit() + OrderSwap() + OrderCommission();
}
}
}
return(profit);
}
{
double profit = 0;
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==TRUE)
{
if(OrderType()>1) continue;
if(TimeToStr(TimeCurrent(),TIME_DATE) == TimeToStr(OrderCloseTime(),TIME_DATE))
{
profit += OrderProfit() + OrderSwap() + OrderCommission();
}
}
}
return(profit);
}
if(OrderType()>1) continue;
| Deleted orders have zero OrderCloseTime, and wouldn't be selected. But there are other entries in history deposits/withdrawals and adjustments (6/7) |
Thank you very much it work fine.
honest_knave:
.
8tango:
Hello,
I would like to calculate the daily profit of one of my EA, my code is:
double DailyProfit()
{
double profit = 0;
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==TRUE)
{
if(TimeToStr(TimeCurrent(),TIME_DATE) == TimeToStr(OrderCloseTime(),TIME_DATE))
{
profit += OrderProfit() + OrderSwap() + OrderCommission();
}
}
}
return(profit);
}
{
double profit = 0;
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==TRUE)
{
if(TimeToStr(TimeCurrent(),TIME_DATE) == TimeToStr(OrderCloseTime(),TIME_DATE))
{
profit += OrderProfit() + OrderSwap() + OrderCommission();
}
}
}
return(profit);
}
But this code return the equity of my account, what is wrong into my code?
Thank you for your help.
//+------------------------------------------------------------------+ //| ProfitDaily.mq4 | //| Copyright 2015, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2015, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- DailyProfit(); } //+------------------------------------------------------------------+ double DailyProfit() { double profit = 0; int i,hstTotal=OrdersHistoryTotal(); for(i=0;i<hstTotal;i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==TRUE) { if(TimeToStr(TimeLocal(),TIME_DATE) == TimeToStr(OrderCloseTime(),TIME_DATE)) { profit += OrderProfit() + OrderSwap() + OrderCommission(); } } } Alert(profit); return(profit); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I would like to calculate the daily profit of one of my EA, my code is:
{
double profit = 0;
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==TRUE)
{
if(TimeToStr(TimeCurrent(),TIME_DATE) == TimeToStr(OrderCloseTime(),TIME_DATE))
{
profit += OrderProfit() + OrderSwap() + OrderCommission();
}
}
}
return(profit);
}
But this code return the equity of my account, what is wrong into my code?
Thank you for your help.