

The relation between lots and margin is linear and is a fixed ratio, based on your type of account, i.e. it's leverage, so simple arithmetic would tell you the maximum number of lots you can open. However, as the open position moves in the negative direction, that would also eat into the margin, so you need to allow for that too. 

blogzr3:
The relation between lots and margin is linear and is a fixed ratio, based on your type of account, i.e. it's leverage, so simple arithmetic would tell you the maximum number of lots you can open. However, as the open position moves in the negative direction, that would also eat into the margin, so you need to allow for that too. ...uhmmm... not quite clear. MarketInfo(Symbol(),MODE_MARGINREQUIRED) returns the margin required to open 1.00 lot... and I expect it takes account of everything already. Let's make an example to clarify what I aim to:  balance 10 000 EUR, no order open yet.  symbol = USDCHF  running MarketInfo(Symbol(),MODE_MARGINREQUIRED) funcion returns > 718.29 ...which means I must have at least 718.29 EUR of free margin to open 1.00 lot position. Now, if I want to know how many lots I can buy/sell with my 10 000 EUR I do the following math: 10 000 / 718.29 = 13.92 What I expect is that 13.92 is the maximum size of an order that the system will accept from my account without raising an error message. Is that correct?



 symbol = USDCHF
 running MarketInfo(Symbol(),MODE_MARGINREQUIRED) funcion returns > 718.29 ...which means I must have at least 718.29 EUR of free margin to open 1.00 lot position. Now, if I want to know how many lots I can buy/sell with my 10 000 EUR I do the following math: 10 000 / 718.29 = 13.92 What I expect is that 13.92 is the maximum size of an order that the system will accept from my account without raising an error message. Is that correct? Sorry, my previous answer was based on the account currency being USD, which is not your case. In your case, the value returned by the MarketInfo function will vary according to the exchange rate. Theoritically, 13.92 is the maximum lot size you can open. Practically, you may need to account for AccountStopOutLevel as phy mentioned, which may be different from broker to broker. 


Zypkin: Is there any other way to check which is the max size in lots I can open with the current freemargin


sysmaya: double Margin=MarketInfo(Symbol(),MODE_MARGINREQUIRED); double FreeMargin=AccountFreeMargin(); double howLots=NormalizeDouble(FreeMargin/Margin,2); Print ("howLots=",DoubleToStr(howLots,2)); 
A question to the gurus of MQL4.
MarketInfo(Symbol(),MODE_MARGINREQUIRED) returns the margin required to open one lot.
Is the realtion between lots and margin required linear? In other words, if I want to open 0.1lots shall I have freemargin > MarketInfo(Symbol(),MODE_MARGINREQUIRED) * 0.1?
...same for volumes > of 1 lot? ...say to open 10lots I need freemargin > MarketInfo(Symbol(),MODE_MARGINREQUIRED) * 10 ???
Is there any other way to check which is the max size in lots I can open with the current freemargin?
Thanks a lot for replies.
Zyp