Calculate free margin that will remain if a specified position has been CLOSED

 

Hello,

we have AccountFreeMarginCheck()
that will calculate the free margin that remains after the specified position has been opened.

But how to calculate what will be the free margin
if we close a certain position (not all of them)?

Thank you

 
There's no function which does that you'll have to calculate it yourself for starter.
 

Yes, I know that there is no such function.
My question is how to calculate it..

Thank you

 

try

double Lots = Your_Lot_Size;
AccountFreeMargin() + (MarketInfo(Symbol(),MODE_MARGINREQUIRED) * Lots);

of course it's not accurate but +-

Reason: