Two orders being opened at same time

 
Hi, im solving small problem.

I have code like if(OrdersTotal()==0): orderSend(Symbol()... OP_BUYSTOP....)
Sometimes it happens that 2 positions are opened in same time. How is that even posible? Is it because new tick comes immediatelly after first one? I mean like OrderSend is just being send somewehere and in new tick OrdersTotal is yet equal 0?

Thank you
 

Foed,

You need to show your code to know exactly what happened ... There are many cases one can consider ...

Like, if the 2 orders are different or the same ?

In case if they are different, the biggest probability is that you need to direct the program flow after each OrderSend( )

to the beginning of the start( ) function using return(0); ... This is only a guess. 

 
Osama Shaban:

Foed,

You need to show your code to know exactly what happened ... There are many cases one can consider ...

Like, if the 2 orders are different or the same ?

In case if they are different, the biggest probability is that you need to direct the program flow after each OrderSend( )

to the beginning of the start( ) function using return(0); ... This is only a guess. 

Thank you for your reaction.

My code is


if((OrdersTotal()==0)

{

int tiket=-1;

tiket=OrderSend(Symbol(),OP_BUYSTOP,in_volume,NormalizeDouble(in_price,Digits),0,0,0,"BUYSTOP",MagicNumber,0,clrBlue);

}

where in_price and in_volume are doubles.

Yes, it opens two ABSOLUTELLY SAME orders :/

Not always, but during stronger moves on instrument.
 
frantisek-fanda:

Thank you for your reaction.

My code is


if((OrdersTotal()==0)

{

int tiket=-1;

tiket=OrderSend(Symbol(),OP_BUYSTOP,in_volume,NormalizeDouble(in_price,Digits),0,0,0,"BUYSTOP",MagicNumber,0,clrBlue);

}

where in_price and in_volume are doubles.

Yes, it opens two ABSOLUTELLY SAME orders :/

Not always, but during stronger moves on instrument.
This code doesn't even compile. Show your real code if you need help.
 
frantisek-fanda: Yes, it opens two ABSOLUTELLY SAME orders :/Not always, but during stronger moves on instrument.
Same EA running on two charts. The if becomes a race condition. Restart the terminal and look at the log.
Reason: