how to convert amount to lot?
chiwing:
203
for Example:
I decide to use $28usd to be Initial margin for selling EURGBP ?
if mt4 acc. leverage = 500
I want the mql4 code : to calculate the lot =? lot
anyone can help?
THANKS
Hello,
can use this formula to calculate the maximum lot based free margin.
//For buy pos AccountFreeMargin()/(AccountFreeMargin()-AccountFreeMarginCheck(Symbol(),OP_BUY,1)) //For sell pos AccountFreeMargin()/(AccountFreeMargin()-AccountFreeMarginCheck(Symbol(),OP_SELL,1))
Formula is:
margin required = (contract size / leverage) * volume_min
possible volume = (your margin / margin required) * volume_min
Here combined:
possible volume = (your margin / ((contract size / leverage) * volume_min)) * volume_min
volume_min is given by the symbol.
IIt is bad practice to calculate your volume from required margin.
your margin must be given in the margin currency of the symbol.You need to exchange it with the current quote between this currency and your account currency.
for Example:
I decide to use $28usd to be Initial margin for selling EURGBP ?
if mt4 acc. leverage = 500
I want the mql4 code : to calculate the lot =? lot
anyone can help?
THANKS