repeat ordersend till its successful

 

i want my function to send an order and if the order is not successful, the order should be sent repeatedly till it is

i know how to check if the send was successful

if(OrderSend(Symbol(),OP_SELLLIMIT,0.01,1.24344,10,0,0,NULL,1234,0,clrRed)==true){Sleep}else{Repeat}

 how do i tell it to repeat the ordersend?

 
Nurudeen Amedu:

i want my function to send an order and if the order is not successful, the order should be sent repeatedly till it is

i know how to check if the send was successful

 how do i tell it to repeat the ordersend?

You could use

do OrderSend()
while Ticket<0

but its not recommended because if the sl or tp or any value is wrong it will result the robot to be stuck in an endless loop.

just a check

if(ticket>0)
 {
  //Ok
 }
else if(ticket<0)
 {
  Print("OrderSend Error!");
 }
 
Marco vd Heijden:

You could use

but its not recommended.

just a check

ok thanks
 
Marco vd Heijden:

You could use

but its not recommended.

just a check

 

how do i count the order to increment ticket value

do i say?

do ticket=OrderSend();
while (ticket<0)

 

 
Nurudeen Amedu:
   do 
     { 
      ticket=OrderSend(.......)
     } 
   while(ticket<0);

But its not recommended it can result in an endless loop and disconnection from the server due to choking requests if your values are not correct.

In stead you can check the return value in most cases it will try to order another time on the next tick if the condition is still valid.

 
Marco vd Heijden:

But its not recommended it can result in an endless loop and disconnection from the server due to choking requests if your values are not correct.

In stead you can check the return value in most cases it will try to order another time on the next tick if the condition is still valid.

thank you very much
 
Marco vd Heijden:

But its not recommended it can result in an endless loop and disconnection from the server due to choking requests if your values are not correct.

In stead you can check the return value in most cases it will try to order another time on the next tick if the condition is still valid.

 

ushort try=0;
do 
     { 
      ticket=OrderSend(.......)
try++;
     } 
   while(ticket<0 && try<200);