I'm a newbie, just learning to make an EA. I found "lot size" problem, please help me ...thanks before.
I'm trying to get the "allowed trading volume" by a broker in MQL. If we trade manually, after we click at "NEW ORDER" using FxOpen Empty4 client, we will get : 0.10, 0.11, 0.12, 0.13, 0.14, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 as Volume (LotStep = 0.01, minLot = 0.1). If we do the same thing at FxPro Empty4 client, we will get 0.1, 0.2, 0.3, 0.4, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 (lotstep = 0.1, minLot = 0.1) (both are MINI account with 0.1 minimal lot).
How to get this value in MQL ?
Some time I got error for "unusual lotsize", like if the order (after lot compounding calculation) is 0.212 lot, I got : error 131 or 4051 message (I think it's a not recognize Lot value error). Then I tried to split it into 2 small Lots ( 2 X 0.1 Lot), It worked fine, without error. But if I tried to split a big lot like splitting 15.52 lots into 155 X 0.1 lot, I got error 148 message (order too much).
I think I can use some big "broker well know lot" and some small lots, like splitting 15.5 lots into : 1 X 8 lot + 1 X 7 lot + 5 X 0.1 lot.
But still don't know how to get the broker's accepted Volume ....
Trying to use this :
Code: Select all
MarketInfo (Symbol(). MODE_MINLOT);
MarketInfo (Symbol(). MODE_MAXLOT);
MarketInfo (Symbol(). MODE_LOTSTEP);
Below is the script I use to Split an "unusual" Lots into several minLots.
Code: Select all
double minLot = MarketInfo(Symbol(), MODE_MINLOT);
switch(NormalizeDouble(minLot,2)) {
case 0.01 :
lotdecimal = 2;
break;
case 0.10 :
lotdecimal = 1;
break;
case 1.00 :
lotdecimal = 0;
break;
}
//---
int lotdecimal_Hilo = lotdecimal;
//---
if (useMM == true) {
MMlots_Hilo = MMcalc(MMriskPercent,MMstopLoss); // calculate Lots
iLots_Hilo = NormalizeDouble(MMlots_Hilo * MathPow(LotExponent_Hilo, NumOfTrades_Hilo), lotdecimal_Hilo);
if (iLots_Hilo < minLot) iLots_Hilo = minLot;
}
//----
int jmlOPSell_Hilo = 0;
if (iLots_Hilo > minLot) { // splitting some Lots
jmlOPSell_Hilo = NormalizeDouble(iLots_Hilo / minLot,0);
} else {
jmlOPSell_Hilo = 1;
}
//---
for (int p=0; p<jmlOPSell_Hilo; p++) {
ticket_Hilo = OpenPendingOrder_Hilo(1, minLot, NormalizeDouble(Bid,Digits), slip_Hilo, NormalizeDouble(Ask,Digits), 0, 0, EAname_Hilo, MagicNumber_Hilo, 0, HotPink);
} // ende for
Gio