is it to buy 100% margin Automatically?

 

I would like to have Function to buy 100%margin.

I do not know calculation method.

Please I would like to know if there is script

 

Use AccountFreeMarginCheck(). Place it within a For() Loop and keep adding Broker Minimum-Lots until the free margin which remains = 0. Then go with the value which triggers 0.

double AccountFreeMarginCheck( string symbol, int cmd, double volume) 
Returns free margin that remains after the specified position has been opened at the current price on the current account. If the free margin is insufficient, an error 134 (ERR_NOT_ENOUGH_MONEY) will be generated. 
Parameters:
symbol   -   Symbol for trading operation. 
cmd   -   Operation type. It can be either OP_BUY or OP_SELL. 
volume   -   Number of lots. 

Sample:
if(AccountFreeMarginCheck(Symbol(),OP_BUY,Lots)<=0 || GetLastError()==134) return;
 

Once you get to 100% margin - One tick against you and margin call - Account blown.

If you look at my code, I can open multiple orders without risk of a margin call.

Reason: