When OrderSymbol() doesn't equal Symbol()

 

Just messing around with code to get it right before implementing - this is to find the first trade of a particular type in the history pool.

Code below + printed output.

Does anybody know why it seems to think that GBPUSD is the same as EURUSD?

void OnStart()
{
  int Magic = 170715;
  for(int i=OrdersHistoryTotal()-1;i>=0;i--)
  {                                                     
   if(OrderSelect(i, SELECT_BY_POS,MODE_HISTORY)== True)       
   {                                                     
    Print(i,"  ",OrderTicket());
    //if order is for this symbol & magic number
    if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == OP_BUY || OrderType() == OP_SELL)
    {
     Print(OrderSymbol(),"  ",Symbol());
     Print(OrderTicket()+"  ",OrderType());
    
     if(OrderType() == OP_BUY && OrderProfit() > 0){Print(Symbol(),"buy > 0");break;}
     if(OrderType() == OP_BUY && OrderProfit() < 0){Print(Symbol(),"buy < 0");break;}
     
     if(OrderType() == OP_SELL && OrderProfit() > 0){Print(Symbol(),"sell > 0");break;}
     if(OrderType() == OP_SELL && OrderProfit() < 0){Print(Symbol(),"sell < 0");break;}
    } 
   }
  }
}

            
 

I think I found the problem: extra brackets!

if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && (OrderType() == OP_BUY || OrderType() == OP_SELL))
Reason: