There's a problem with AccountInfoDouble(ACCOUNT_BALANCE) function. When I close a position inside OnTick() and then execute AccountInfoDouble(ACCOUNT_BALANCE), it returns the account balance before the position was closed.
It's easy to reproduce by calling the function immediately before and after closing a position inside OnTick().
If it's not a bug, how do I effectively get the current account balance after I've closed a position inside OnTick()?
Sending order to close position doesn't mean closeing position. You should check that deal based on your order was appeared and executed.