OrderSend for very high lotsizes

 

Hello,

I was searching the forum but didn't find any topic about this, sorry if I'm just blind :-)

Here's my problem:

I have a client who trades huge accounts and I found that for very high lotsizes, the EA won't open any trades, rather it returns error 3 (invalid trade parameters).

I have also found that the trade request is somehow different in the log than if I succesfully open lower lotsize.

Example:

Here is one successfull trade:

21:00:15 '000000': order buy market 18.40 EURUSD sl: 0.00000 tp: 0.00000
21:00:16 '000000': request was accepted by server

21:00:16 '000000': request in process

21:00:16 '000000': order was opened : #000000 buy 18.40 EURUSD at 1.23257 sl: 0.00000 tp: 0.00000


and here is an unsuccessfull one:


03:32:44 '000000': request 36.90 EURUSD
03:32:45 '000000': request was accepted by server
03:32:45 '000000': answer 36.90 EURUSD 1.23096 / 1.23112
03:32:45 '000000': order by request buy 36.90 EURUSD at 1.23112 sl: 0.00000 tp: 0.00000

03:32:46 '000000': order buy 36.90 EURUSD opening at 1.23112 sl: 0.00000 tp: 0.00000 failed [Invalid parameters]


Notice that "request" and "answer".

I assume that this happens for trades over some specific lotsize and it can be set by the broker to prevent very large trades to be opened by the EA, or at least to let the broker decide manually if they can open the trade.


So my question is, is there any way how to handle this in MQL4? Or I simply can't open trades via EA which are higher lotsize than the value set by broker?


Hope that someone knows the answer :-)

By the way I was also able to replicate this behaviour using ac-markets 500k demo account, so if someone wants to play with it, feel free. I was able to open 18 lots, but unable to open 36 lots with the EA, so I assume the treshold is something like 20-30 lots there. I was able to open even 50 lots without any problems manually.

Thanks!

 

Check the return of MarketInfo(Symbol(),MODE_MAXLOT).

CB

 
So my question is, is there any way how to handle this in MQL4? Or I simply can't open trades via EA which are higher lotsize than the value set by broker?
On IBFX maxlot = 50. Larger than that, you'll need to open multiple orders
double  LotStep = MarketInfo(Symbol(), MODE_LOTSTEP),   // IBFX= 0.01
        maxLot  = MarketInfo(Symbol(), MODE_MAXLOT );   // IBFX=50.00
// If a zone size is bigger than maxlot, it must be split.
for (int split=MathCeil(lotsNew/maxLot); split>0; split--){
    // 50.00+49.99=99.99    25.01+25.00+25.00+25.00=100.01
    if (split == 1) double size=lotsNew;
    else                   size=MathCeil(lotsNew/split/LotStep)*LotStep;
    lotsNew -= size;
    RefreshRates()
    oo.ticket   = OrderSend(Symbol(),       OP_BUY,         size,
                            Ask,            Slippage.Pips * pips2points,
                            NO_SL,          NO_TP,          reason,
                            magic.number,   NO_EXPIRATION,  op.color );
   ...
 
William Roeder:
On IBFX maxlot = 50. Larger than that, you'll need to open multiple orders
I do not understand how this code allows you to send split orders of size.
In the best case  it allows you 1 order of size.
 
It does exactly what the comment says. If you ask for 100.01 with a broker max of 50 you get three orders of 25.0 and one of 25.01. Ceil(100.01/50)=3 split=[3…0] Four orders.
 
William Roeder:
It does exactly what the comment says. If you ask for 100.01 with a broker max of 50 you get three orders of 25.0 and one of 25.01. Ceil(100.01/50)=3 split=[3…0] Four orders.
Thanks a lot 
Reason: