Sending several orders at same time without waiting for execution..

 

Hi guys,

Is there a way in MT4 to send several orders at the same tick time without waiting for each order to be executed..

I mean market orders, not pendind conditional orders..

THANKS

 
Volcanbleu:

Hi guys,

Is there a way in MT4 to send several orders at the same tick time without waiting for each order to be executed..

I mean market orders, not pendind conditional orders..

THANKS

Not with MT4's available tools.

There are some helpful scripts for such actions in Codebase and the Market.

 
Volcanbleu:

Hi guys,

Is there a way in MT4 to send several orders at the same tick time without waiting for each order to be executed..

I mean market orders, not pendind conditional orders..

THANKS

Yes, with conditions.

  1. within step sequence function. (finite numbers of order that is predefined within the function)
  2. same symbol
although, there is no guarantee that the orders will be execute at the same price.

 
You can. In fact you can send up to eight pseudo-asynchronous orders at a time before you run into the trade context busy error. The easiest way to pull it off is to run EA "clients" on offline charts whose job it is to receive custom chart events which include instructions for order processing. So in the main EA you would iterate over a list of client EA charts and send order commands which they, in-turn, will handle in their own threads. 
 

Hi Mohamad..


Thanks for your reply. Could you be more explicite about your 1. condition ? Yes it is for same symbol ...

 

Thanks Emma,


It is a good idea, but quite heavy to setup with several EA's
 
Volcanbleu:

Thanks Emma,


It is a good idea, but quite heavy to setup with several EA's

No worries, however, multiple EAs is the only way to send async orders with MT4, and it's really no work at all once you launch your charts and apply the EA templates programmatically. 

 
Volcanbleu:

Hi Mohamad..

Thanks for your reply. Could you be more explicite about your 1. condition ? Yes it is for same symbol ...

example psedo-code function code below applied to script (it's  single tick execution)
i know it's not the best hardcoding example, but you get my point.

you need to specify finite numbers of order in the function (below case, 5 with different magic number)

void MultipleMarketOrder()
{
   RefreshRates();
   int ticket1 = OrderSend(_Symbol,OP_BUY,0.01,Ask,slippage,0,0,"",magic1);
   while(IsTradeContextBusy()) Sleep(1);
   int ticket2 = OrderSend(_Symbol,OP_BUY,0.01,Ask,slippage,0,0,"",magic2);
   while(IsTradeContextBusy()) Sleep(1);
   int ticket3 = OrderSend(_Symbol,OP_BUY,0.01,Ask,slippage,0,0,"",magic3);
   while(IsTradeContextBusy()) Sleep(1);
   int ticket4 = OrderSend(_Symbol,OP_BUY,0.01,Ask,slippage,0,0,"",magic4);
   while(IsTradeContextBusy()) Sleep(1);
   int ticket5 = OrderSend(_Symbol,OP_BUY,0.01,Ask,slippage,0,0,"",magic5);
}

however, if you applied it to EA, you need to specify which incoming tick to execute the function.
the best would be at the beginning of newbar.

if(NewBar(PERIOD_M5) && TimeCurrent()==SomeTime) MultipleMarketOrder();

hope it helps.

 
Mohamad Zulhairi Baba:

example psedo-code function code below applied to script (it's  single tick execution)
i know it's not the best hardcoding example, but you get my point.

you need to specify finite numbers of order in the function (below case, 5 with different magic number)

however, if you applied it to EA, you need to specify which incoming tick to execute the function.
the best would be at the beginning of newbar.

hope it helps.

I think this is what OP is trying to avoid since this is an example of synchronous operation... In this example; order#1 is sent to the broker-server and the function waits for a result. Only after confirmation of order#1 and checking the trade context can it proceed to place order#2, which could take seconds. 

 
void OpenOrders( const int    ordes,
                 const int    type,
                 const double lot,
                 const int    slippage,
                 const double sl,
                 const double tp,
                 const string comment,
                 const int    magic)
{
     if( type != OP_BUY && type != OP_SELL ) return;
     for(int cnt=0; cnt<ordes; cnt++)
          if( OrderSend( _Symbol,
                         type,
                         lot,
                         (OP_BUY ? Ask : Bid),
                         slippage,
                         sl,
                         tp,
                         comment,
                         magic) ) continue;
}
 
Emma Schwatson:

I think this is what OP is trying to avoid since this is an example of synchronous operation... In this example; order#1 is sent to the broker-server and the function waits for a result. Only after confirmation of order#1 and checking the trade context can it proceed to place order#2, which could take seconds. 

ah my bad, re-read the OP question, your solution is way to go.

Reason: