OrderMagicNumber in e-mini S&P trading

 
For currency trading in MT4, we use magic numbers to identify individual trade. For the e-mini S&P trading, can we still use magic number? 
 

Yes

magic number is used to identify trades by a particular EA, not necessarily a particular symbol 

 

Can someone explain this for me? When I am trading the EURUSD, I can use this routine to count orders and it works fine.

  

void Jas_CountOrder(int Jas_i5)
{
   datetime dt = 0;
   nAll = 0;
   nBuy = 0;
   nSell = 0;
   
   for(int i=OrdersTotal()-1; i>=0; i--) 
   {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if(OrderMagicNumber() != Jasmine_magic[Jas_i5]) continue;
      if(OrderSymbol() != NULL) continue;
      nAll++;
      if(OrderType() == OP_BUY)  nBuy++ ;
      if(OrderType() == OP_SELL) nSell++;
   }
}

   

When I am trading the E-mini S&P, I have to comment out // if(OrderSymbol() != NULL) continue. If I don't then I don't get accurate count of the CountOrder.

 

void Jas_CountOrder(int Jas_i5)
{
   datetime dt = 0;
   nAll = 0;
   nBuy = 0;
   nSell = 0;
   
   for(int i=OrdersTotal()-1; i>=0; i--) 
   {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
      if(OrderMagicNumber() != Jasmine_magic[Jas_i5]) continue;
     // if(OrderSymbol() != NULL) continue;
      nAll++;
      if(OrderType() == OP_BUY)  nBuy++ ;
      if(OrderType() == OP_SELL) nSell++;
   }
}
 

I would never use NULL in your context! In some exists a replacement for NULL but - I am pretty sure - not here at least it's not save!

To exclude the non-chart-symbol use _Symbol (or Symbol()) instead!!

 
gooly:

I would never use NULL in your context! In some exists a replacement for NULL but - I am pretty sure - not here at least it's not save!

To exclude the non-chart-symbol use _Symbol (or Symbol()) instead!!

Awesome, thank you. 
Reason: