PositionGetDouble(POSITION_VOLUME) does not update after SL order

 

Hi all, 

Any idea why PositionGetDouble(POSITION_VOLUME) does not update its value after being stopped by SL order ?

void OnTick()
{
(...)
   if(PositionSelect(my_symbol)) // seleciona a posição
     {
      ContratosAtual=PositionGetDouble(POSITION_VOLUME);
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY) orderAtual=1;
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL) orderAtual=-1;
      Relatorio("COM POSICAO");
     }
(...)
         mrequest.price=NormalizeDouble(price_info.bid,_Digits);               // latest bix price
         mrequest.sl=NormalizeDouble(price_info.bid+stop_loss*_Point,_Digits); // Stop Loss (SELL)
(...)
}
 
YouTrade:

Hi all, 

Any idea why PositionGetDouble(POSITION_VOLUME) does not update its value after being stopped by SL order ?

Sorry but your question is not clear ? If SL was reached, there is no more position.
 
angevoyageur:
Sorry but your question is not clear ? If SL was reached, there is no more position.

Yes ... the SL order was reached. The next OnTick(), I was expecting the ContratosAtual=PositionGetDouble(POSITION_VOLUME) changed to 0 (zero) but instead, it remains with the same value as it was before.

So my question is do I have run any Refresh() command ?

 
YouTrade:

Yes ... the SL order was reached. The next OnTick(), I was expecting the ContratosAtual=PositionGetDouble(POSITION_VOLUME) changed to 0 (zero) but instead, it remains with the same value as it was before.

So my question is do I have run any Refresh() command ?

Your PositionSelect() should return false if you don't have a position. If you don't have a position there is no point the check POSITION_VOLUME.

If your PositionSelect() returns true, and so the volume is unchanged, that means the terminal is not yet aware your position was closed.

 
angevoyageur:

Your PositionSelect() should return false if you don't have a position. If you don't have a position there is no point the check POSITION_VOLUME.

If your PositionSelect() returns true, and so the volume is unchanged, that means the terminal is not yet aware your position was closed.

Thank you
 
YouTrade:
Thank you
Solved ! Thank you !
Reason: