remove it
Thanks! But it's not work
I want to calculate the total profit for all market deal.
Please help me!
It is very strange that the classes work differently when tested and run in production mode. All the same, we are operating here with money, and not something else.
Thanks! But it's not work
I want to calculate the total profit for all market deal.
Please help me!
You need to look for market exit trades (DEAl_ENTRY_INOUT and DEAL_ENTRY_OUT).
falto cargar el historial
datetime from_date=0;
datetime to_date=TimeCurrent();
HistorySelect(from_date,to_date);
Hello everybody, see at my solution which works fine as a function to display the profit of last order closed.
double LastResult(uint nbHist, ulong magic)
{
double orderResult = 0;
if (nbHist > 0)
{
for (int i = nbHist - 1; i >= 0; i--)
{
ulong ticket = HistoryDealGetTicket(i);
HistoryDealGetTicket(ticket);
if (HistoryDealGetDouble(ticket,DEAL_PROFIT))
{
if ((magic > 0 && HistoryDealGetInteger(ticket,DEAL_MAGIC) != magic) || HistoryDealGetString(ticket,DEAL_SYMBOL) != _Symbol)
continue;
orderResult = HistoryDealGetDouble(ticket, DEAL_PROFIT)+
HistoryDealGetDouble(ticket, DEAL_COMMISSION) +
HistoryDealGetDouble(ticket, DEAL_SWAP);
break; // Exit the loop once the last matching trade is found
}
}
}
return(orderResult);
}
/* don't forget put these includes in the main structure :
#include <Trade\DealInfo.mqh>
#include <Trade\HistoryOrderInfo.mqh>
*/

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
My funtion:
I backtest, but it's always =0.
Please help me!
Thanks!