# Two orders being opened at same time

24
2016.10.24 13:42
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
1302
2016.10.24 16:48

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.

5
2016.10.24 17:51
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.

My code is

if((OrdersTotal()==0)

{

int tiket=-1;

}

where in_price and in_volume are doubles.

Yes, it opens two ABSOLUTELLY SAME orders :/

Not always, but during stronger moves on instrument.
Moderator
28518
2016.10.25 08:35
frantisek-fanda:

My code is

if((OrdersTotal()==0)

{

int tiket=-1;

}

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.
13589
2016.10.25 15:28
 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.
/