# HistoryDealGetDouble(ticket, DEAL_PROFIT) always = 0.0?

Hi all,

My funtion:

```double ProfitCheck(long const magic_number)
{
double profit=0.0;
HistorySelect(0, TimeCurrent());

for(int i=0; i < trades_total; i++)
{
long ticket = HistoryDealGetTicket(i);
long type   = HistoryDealGetInteger(ticket, DEAL_TYPE);

//--- Initial deposit is not considered
if((i == 0)&&(type == DEAL_TYPE_BALANCE)) continue;

if((type != DEAL_TYPE_BUY)&&(type != DEAL_TYPE_SELL)) continue;

if( magic_number != HistoryDealGetInteger(ticket, DEAL_MAGIC)) continue;

//--- Calculation of profit
Print(   "Ticket: "        + ticket +
" type: "         + type +
" DEAL_SYMBOL: "  + HistoryDealGetString(ticket,DEAL_SYMBOL) +
" DEAL_VOLUME: "  + HistoryDealGetDouble(ticket, DEAL_VOLUME) +
" DEAL_PROFIT: "  + HistoryDealGetDouble(ticket, DEAL_PROFIT) +
" DEAL_COMMISSION: " + HistoryDealGetDouble(ticket, DEAL_COMMISSION) +
" DEAL_SWAP: "    + HistoryDealGetDouble(ticket, DEAL_SWAP));

profit =+ HistoryDealGetDouble(ticket, DEAL_PROFIT) +
HistoryDealGetDouble(ticket, DEAL_COMMISSION) +
HistoryDealGetDouble(ticket, DEAL_SWAP);

}
return(profit);
}```

I backtest, but it's always =0.

Thanks!

remove it

` if((type != DEAL_TYPE_BUY)&&(type != DEAL_TYPE_SELL)) continue;`

Nguyen Nga:

remove it

Thanks! But it's not work

I want to calculate the total profit for all market deal.

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.

Hung Dinh Van :

Thanks! But it's not work

I want to calculate the total profit for all market deal.