max lots size to trade with

 

I have the following question:

 how can I calculate the Lots I can use to enter a trade?(say the max lots size)

 for an account of say 100 $( the deposit ) and leverage 10:1 then following the logic I would have: max_lot_size= leverage * balance /1e5 = 0.01?

 I receive an error - not enough moeny ... 4753 :)

 ... 

 
dudenukem:

I have the following question:

 how can I calculate the Lots I can use to enter a trade?(say the max lots size)

 for an account of say 100 $( the deposit ) and leverage 10:1 then following the logic I would have: max_lot_size= leverage * balance /1e5 = 0.01?

 I receive an error - not enough moeny ... 4753 :)

 ... 

Lot size is determined by free margin and cost of 1 lot in base currency (left side currency of the pair) and not the account currency!

So it would be something like: max lot size = AccountFreeMargin/OrderCalcMargin(for 1 lot).

See the detail of the syntax in the documentation.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
 

it doesn't seem to work - in order to get rid of the annoying error I need to increase the deposit in the tester : the Lot (volume ) for the order is calculated by:


OrderCalcMargin(ORDER_TYPE_BUY,tradeReq.symbol,tradeReq.volume,tradeReq.price,tmpMargine);//tradeReq.volume=1

on success the volume to trade is calculated by


tradeReq.volume=AccountInfoDouble(ACCOUNT_FREEMARGIN)/tmpMargine;


to no avail I get the not enough money notification ....

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
 

put it in another way:

how to calculate the amount in lots for

MqlTradeResult volume?

so that you will not get the not enough money error?

Documentation on MQL5: Standard Constants, Enumerations and Structures / Data Structures / Structure of a Trade Request Result
  • www.mql5.com
Standard Constants, Enumerations and Structures / Data Structures / Structure of a Trade Request Result - Documentation on MQL5