Help ... how to know broker's accepted volume ?

 
Hi,

Any one can help me please .... 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 MT4 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. If we do the same thing at FxPro MT4 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 (both are MINI account with 0.1 minimal lot).
How to get this value in MQL ?

I've tried to make an EA to make order with some "unusual lot", 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.52 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 ....

[CODE]
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

[/CODE]


*) Without splitting the compounding lots, i got error 131 or 4051.
So, I split the lot, make some orders with the smallest lot (minLot) at the same price.
*) But splitting the VERY BIG lots, i got error 148.

Any idea ?
Thanks
Gio
 


Sorry, forgot. This is the screenshot.

 

Hi giovanni,

Please re-post your code using SRC butt-on, so your code much easier to read

  MarketInfo (Symbol(). MODE_MINLOT);
  MarketInfo (Symbol(). MODE_MAXLOT);
  MarketInfo (Symbol(). MODE_LOTSTEP);

 

Hi onewithzachy,

Thanks for your reply. Ok, this is the code & images. I tried to use the MarketInfo(Symbol(), MODE_MAXLOT), but the result (1,000 or 10,000) is not the same as we click at "New Order" (8 lot).

Thank you





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
 
giovanni:

Hi onewithzachy,

Thanks for your reply. Ok, this is the code & images. I tried to use the MarketInfo(Symbol(), MODE_MAXLOT), but the result (1,000 or 10,000) is not the same as we click at "New Order" (8 lot).

Thank you

Hi giovanni,

That lot size in new order window is not important, it's what MetaQuotes set for 'New Order' window, not what broker set. We can type any lot value on that new order window as long as it does not violate market info's MODE_MAXLOT, MODE_MINLOT, or MODE_LOTSTEP.

Try this, click the field, not the drop down arrow and just type any value of lot that you want.

The minimum lot that allowed by broker is set by MarketInfo (Symbol(). MODE_MINLOT), if we want to increase the lot size just add several MarketInfo (Symbol(). MODE_LOTSTEP) to that min lot. For example

 int number_of_step = 7;
 double Lot_Size;

 Lot_Size = MarketInfo (Symbol(). MODE_MINLOT) + ( number_of_step * MarketInfo (Symbol(). MODE_LOTSTEP));

 if (Lot_Size > MarketInfo (Symbol(). MODE_MAXLOT)) Lot_Size = MarketInfo (Symbol(). MODE_MAXLOT);


 
onewithzachy:

Hi giovanni,

That lot size in new order window is not important, it's what MetaQuotes set for 'New Order' window, not what broker set. We can type any lot value on that new order window as long as it does not violate market info's MODE_MAXLOT, MODE_MINLOT, or MODE_LOTSTEP.

Try this, click the field, not the drop down arrow and just type any value of lot that you want.

The minimum lot that allowed by broker is set by MarketInfo (Symbol(). MODE_MINLOT), if we want to increase the lot size just add several MarketInfo (Symbol(). MODE_LOTSTEP) to that min lot. For example



Hi onewithzachy,

Thank you very much bro .... it's very helpful ...

BR,
Gio

 
double minLot = MarketInfo(Symbol(), MODE_MINLOT);
switch(NormalizeDouble(minLot,2)) {
case 0.01 :
lotdecimal = 2;
break; ...
  1. Do not use NormalizeDouble EVER. It's a kludge https://www.mql5.com/en/forum/137301 and unnecessary https://www.mql5.com/en/forum/136997/page2#593570
  2. Your use assumes min lot and lot step are multiples of 1/10 or 1/100. Your code fails for any other. Do it right
    double NormalizePrice(double p, string pair=""){
        // https://forum.mql4.com/43064#515262 zzuegg reports for non-currency DE30:
        // MarketInfo(chart.symbol,MODE_TICKSIZE) returns 0.5
        // MarketInfo(chart.symbol,MODE_DIGITS) return 1
        // Point = 0.1
        // Prices to open must be a multiple of ticksize
        if (pair == "") pair = Symbol();
        double ts = MarketInfo(pair, MODE_TICKSIZE)
        return( MathRound(p/ts) * ts );
    }
    double NormalizeLots(double lots, string pair=""){
        if (pair == "") pair = Symbol();
        double  lotStep     = MarketInfo(pair, MODE_LOTSTEP),
                minLot      = MarketInfo(pair, MODE_MINLOT);
        lots            = MathRound(lots/ls) * ls;
        if (lots < minLot) lots = 0;    // or minLot
        return(lots);
    }
    

 
WHRoeder:
  1. Do not use NormalizeDouble EVER. It's a kludge https://www.mql5.com/en/forum/137301 and unnecessary https://www.mql5.com/en/forum/136997/page2#593570
  2. Your use assumes min lot and lot step are multiples of 1/10 or 1/100. Your code fails for any other. Do it right

Owye ... this is new for me .... thank you very much bro ...

So, instead of using "NormalizeDouble" I can use the code you wrote, right ? I will try it ....

Thanks
Gio

Reason: