Download MetaTrader 5
To add comments, please log in or register
Publish your article and get a reward!
james
24
james 2014.06.11 23:49 
Hi, i am with dukascopy. They allow conversion of mql4 indicators to java to use with them, and as i am familiar with mql4 i like to code my indicators in that and then have dukas compile it in jfx. Now, dukas allows you to trade in individual units, e.g 1000 units is 0.01 lot. Now if i wanted to enter a specific amount of units, lets say 1364 units then how would i code an mql4 ea to do this? I tried using 0.01364 but it doesn't work. Thanks!
Drazen Penic
2408
Drazen Penic 2014.06.12 00:04  

You need to check minimal lot size defined by the broker and lot step. 

If broker has lot step 0.01 lot, then you can have lot size on two decimals, providing that it is not less than minimum lot size required by the broker. 

For example I saw brokers that have minimum lot size 0.10 and lot step 0.01 , so you could open order with 0.11 lots but not 0.09.

 

Here is excerpt from example you can find here: https://docs.mql4.com/constants/environment_state/marketinfoconstants 

Print("Minimum permitted amount of a lot=",MarketInfo(Symbol(),MODE_MINLOT));
Print("Step for changing lots=",MarketInfo(Symbol(),MODE_LOTSTEP));
whroeder1
13640
whroeder1 2014.06.12 13:50  
dekpips:  1000 units is 0.01 lot. Now if i wanted to enter a specific amount of units, lets say 1364 units
You can't. You can only trade multiples of LOTSTEP and a minimum of MINLOT
double tradeSize  = 1364;
double cntrctSize = SymbolInfoDouble(Symbol(), SYMBOL_TRADE_CONTRACT_SIZE); // 1000
double lots = NormalizeLots(0.01*tradeSize/cntrctSize); // 0.01 If lotstep=0.01
                                                        // 0.013 if lotstep=0.001
/
To add comments, please log in or register