How to check if order with some ID exist?

 

Hi, I want to check if order exist.

For example;

if(order with magic number=11111 exist)

{

Send pending order.......

Can you help me?

 

I say also that I'm trying to make it like that:

double ABUY;

ABUY=(OrderSelect(SELECT_BY_TICKET)OrderMagicNumber() == 11111);

if (ABUY>=1)

{ // Send pending 0rder......

Can Anyone tell me how to do that good?

 
BorysekPL:

I say also that I'm trying to make it like that:

double ABUY;

ABUY=(OrderSelect(SELECT_BY_TICKET)OrderMagicNumber() == 11111);

if (ABUY>=1)

{ // Send pending 0rder......

Can Anyone tell me how to do that good?

The point is that you can't select by magic number - directly. You presumably want to check if there is an open order with that magic number. So check OrdersTotal(). If this is non-zero then you have either market or pending orders present. Now you can step though each open order in a loop and test to see if that open order has the correct magic number. This code should give you an idea of how to achieve what you want. I have #define'ed MAGICNUMBER earlier in the program.

   int total= OrdersTotal();
   for( n=0; n<total; n++ ){
      if( !OrderSelect(n,SELECT_BY_POS,MODE_TRADES) )
         continue;

      if( OrderSymbol()!=Symbol() )
         continue;
      
      if( OrderMagicNumber()!=MAGICNUMBER )
         continue;
         
      if( OrderType()== OP_BUY )
         longCountNEW++;
      else if( OrderType()== OP_SELL )
         shortCountNEW++;
   }
 
dabbler:

The point is that you can't select by magic number - directly. You presumably want to check if there is an open order with that magic number. So check OrdersTotal(). If this is non-zero then you have either market or pending orders present. Now you can step though each open order in a loop and test to see if that open order has the correct magic number. This code should give you an idea of how to achieve what you want. I have #define'ed MAGICNUMBER earlier in the program.


Thank you, really help me:)

now it's going to be much easier ....