selecting a pair - and checking if a trade exists or not on that pair?

 
loop through open orders . . . OrderSelect() then if (OrderSymbol() == "your pair")
 
RaptorUK:
loop through open orders . . . OrderSelect() then if (OrderSymbol() == "your pair")


yea that is what i have. But that does not work if there is an open trade on DIFFERENT pair.

if (OrderSymbol()!=Symbol()) return(true); this works if i have trades open on one piar only. But if i have trades open on any different pairs the this will ALWAYS RETURN TRUE as it cycles through the loop.

What i woul;d really need is this >> if (Symbol()!= OrderSymbol()) selecting the symbol and then seeing iof an existing trade matched with it. But this does not work!!

I dont know..

 

This isn't the code that you need but you will probably see what you do need.

int CheckPosition(int magic,string sym=""){
   
   ticket = -1;

   if( sym=="" )
       sym=Symbol();
   
   for( int n=OrdersTotal()-1; n>=0; n-- ){
      if( !OrderSelect(n,SELECT_BY_POS,MODE_TRADES) )
         continue;
      
      if( OrderSymbol() != sym )
         continue;
         
      if( OrderMagicNumber() != magic )
         continue;
      
      ticket = OrderTicket();
      if( OrderType()==OP_BUY )
         return( LONGPOSITION );
      
      if( OrderType()==OP_SELL )
         return( SHORTPOSITION );
      
      return( PENDINGORDER );
   }
   
   return( NOPOSITION );
}
 
dabbler:

This isn't the code that you need but you will probably see what you do need.



Ok, I will see what i can do with that on monday and hopefully i get it sorted.

thanks...

 
    for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if (
        OrderSelect(iPos, SELECT_BY_POS)                    // Only my orders w/
    &&  OrderMagicNumber()  == Magic.Number                 // my magic number
    &&  OrderSymbol()       == chart.symbol                 // and my pair.
    ){
        // found one.
Reason: