Download MetaTrader 5
To add comments, please log in or register
Ask your broker to open the official channel. Thousands of traders will read the news!
Foed
24
Foed 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
Osama Shaban
1302
Osama Shaban 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. 

frantisek-fanda
5
frantisek-fanda 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. 

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.
Alain Verleyen
Moderator
28518
Alain Verleyen 2016.10.25 08:35  
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.
whroeder1
13589
whroeder1 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.
/
To add comments, please log in or register