I could be wrong, but is closing a position supposed to immediately change the balance?

 
I could be wrong, but is closing a position supposed to immediately change the balance? Is something else at play, like the settlement period?
 
Westie30:
I could be wrong, but is closing a position supposed to immediately change the balance? Is something else at play, like the settlement period?
I’ve been trading for awhile. I’ve used several different brokers over the years. I’ve never experienced a time when my account wasn’t changed immediately after closing a position.
 
Jhsdo1:
I’ve been trading for awhile. I’ve used several different brokers over the years. I’ve never experienced a time when my account wasn’t changed immediately after closing a position.

Right now I don't have a broker, so I'm just using a default MT5 demo account. I'm also back testing an EA, so do you know if there's something I'm missing, like a function call to update the balance?

 
Westie30:

Right now I don't have a broker, so I'm just using a default MT5 demo account. I'm also back testing an EA, so do you know if there's something I'm missing, like a function call to update the balance?

This is what is happening in my journal log:


conditions met to close short position

Short position closed

New positions closed, 0 open positions remain

Equity = 295.7 Margin = 218.98 Balance = 300

 
Westie30:

This is what is happening in my journal log:


conditions met to close short position

Short position closed

New positions closed, 0 open positions remain

Equity = 295.7 Margin = 218.98 Balance = 300

Are you sure 0 position remains ? Sending a request to close doesn't mean the position is already closed.
 
Alain Verleyen:
Are you sure 0 position remains ? Sending a request to close doesn't mean the position is already closed.
You are right, I am having difficulty closing my positions. It is saying I have an invalid request.
if((Short_Position_Exit_1 || Short_Position_Exit_2) && positionStatus==2)
  {
  Print("conditions met to close short position");
  //ZeroMemory(mrequest);
  //ZeroMemory(mresult);
  mrequest.action=TRADE_ACTION_CLOSE_BY;                         // type of trade operation
  mrequest.price=NormalizeDouble(latest_price.ask,_Digits);
  //mrequest.sl=NormalizeDouble(latest_price.ask+STP*_Point,_Digits);
 // mrequest.tp=NormalizeDouble(latest_price.bid-TKP*_Point,_Digits);
  //Print("Attempmted stop value: ",NormalizeDouble(latest_price.bid+STP*_Point,_Digits));
  mrequest.symbol=_Symbol;
  //mrequest.volume=Lot;
  mrequest.magic=EA_Magic;
  mrequest.type=ORDER_TYPE_CLOSE_BY;
  //mrequest.type_filling=ORDER_FILLING_FOK;
  //mrequest.deviation=100;
  OrderSend(mrequest,mresult);
 
 
  Print("Short position closed");
  
  Print("New positions closed",PositionsTotal());
positionStatus=0;
Print("Equity = ",currentSymbol.Equity(),"FreeMargin = ",currentSymbol.FreeMargin(),"Balance =",currentSymbol.Balance()); 


}
 
Westie30:
You are right, I am having difficulty closing my positions. It is saying I have an invalid request.

Use CTrade if you can't manage to work with OrderSend() directly.

 
Alain Verleyen:

Use CTrade if you can't manage to work with OrderSend() directly.

I tried CTrade with "trade.PositionClose(Symbol())" but couldn't get it to work.
#include <Trade\Trade.mqh>
#include <Trade\AccountInfo.mqh>
#include <Object.mqh>
CTrade trade;

code...

trade.PositionClose(Symbol());
 
Alain Verleyen:

Use CTrade if you can't manage to work with OrderSend() directly.

I got it working now, but when I try to use the cloud agents for optimization, they just say "ready" as opposed to "processing."