EA backtest not updating profit

 

EA runs very well on real market. But during backtests, profit is not being updated as you can see:

Orders are being filled, but in the end of simulation account balance remains the same as open balance (in this case 1.000.000 USD).

On code below

if(PositionSelect(_Symbol) == true) // We have an open position
   {
      saida = false;
      if (TimeSession(16,45,16,54,TimeCurrent()))
      { 
         Print(_Symbol, "Lucro atual:",PositionGetDouble(POSITION_PROFIT), ". Lucro venda: ", PositionGetDouble(POSITION_PRICE_OPEN)*PositionGetDouble(POSITION_VOLUME)*(ExitMargin/100+custostrade) ,"."); 
         if(PositionGetDouble(POSITION_PROFIT) >= PositionGetDouble(POSITION_PRICE_OPEN)*PositionGetDouble(POSITION_VOLUME)*(ExitMargin/100+custostrade))
         {
            saida = true;
            Print(_Symbol, ": exit on minimal margin with price equals ",PositionGetDouble(POSITION_PRICE_CURRENT) ,"."); 
         }

PositionGetDouble(POSITION_PROFIT) is always returning 0, so if(PositionGetDouble(POSITION_PROFIT) >= PositionGetDouble(POSITION_PRICE_OPEN)*PositionGetDouble(POSITION_VOLUME)*(ExitMargin/100+custostrade)) never returns true since ExitMargin and custostrade are both > 0.

PositionGetDouble(POSITION_PRICE_OPEN) and PositionGetDouble(POSITION_VOLUME) returns correct value. So, at this point, position is open and selected.

Why PositionGetDouble(POSITION_PROFIT) is returning 0 during Strategy Tester and working fine on real time?

 
ServerName?
 
fxsaber:
ServerName?

CLEAR-Demo

 
hdemarco:

CLEAR-Demo

I can not open a demo account. Open another demo account and send it to me in private messages.

 

Folks,

I've found the problem: account is in BRL and Strategy Tester was running in USD.


Incredible how stupid I was.

Thanks for your help @fxsaber

Reason: