Topic: Daily Profit Calculation
Hi,
@Popov is the current Daily Profit calculation depends on the MT4 account? When i use 2-3-4 Portfolio EAs at once he calculates the daily profit of alle EAs or only for the one EA?
Cause when i look in code i think there is missing something in code that for only the magicnumber it have to calculate or i am wrong?
double CalculateDailyProfit()
{
const datetime t0 = TimeCurrent();
const datetime t1 = t0 - 60*60*24;
double dailyProfit = 0.0;
const int totalOrders = OrdersTotal();
for(int i=0; i < totalOrders; i+=1) {
if(OrderSelect(i, SELECT_BY_POS)) {
if((OrderCloseTime() > t1 && OrderCloseTime() <= t0) ||
OrderCloseTime() == 0) {
if(OrderType() <= OP_SELL) {
dailyProfit += OrderProfit();
dailyProfit -= OrderSwap();
dailyProfit -= OrderCommission();
}
}
}
}
return dailyProfit;
}
didnt it have to be such code than
double CalculateDailyProfit()
{
[b] int minMagic = GetMagicNumber(0);
int maxMagic = GetMagicNumber(strategiesCount);[/b]
const datetime t0 = TimeCurrent();
const datetime t1 = t0 - 60*60*24;
double dailyProfit = 0.0;
const int totalOrders = OrdersTotal();
for(int i=0; i < totalOrders; i+=1) {
if(OrderSelect(i, SELECT_BY_POS)) {
[b] int magicNumber = OrderMagicNumber();
if (magicNumber >= minMagic && magicNumber <= maxMagic)[/b]
if((OrderCloseTime() > t1 && OrderCloseTime() <= t0) ||
OrderCloseTime() == 0) {
if(OrderType() <= OP_SELL) {
dailyProfit += OrderProfit();
dailyProfit -= OrderSwap();
dailyProfit -= OrderCommission();
}
}
}
}
return dailyProfit;
}
So this code only read daily profit of the magicnumber of the ea and only this close.