Download MetaTrader 5
To add comments, please log in or register
Do you need private account monitoring? The Signals will provide you one!
Winsor Hoang
4743
Winsor Hoang 2014.12.08 04:30 
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? 
Keith Watford
Moderator
7990
Keith Watford 2014.12.08 04:36  

Yes

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

Winsor Hoang
4743
Winsor Hoang 2014.12.08 15:22  

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++;
   }
}
Carl Schreiber
5962
Carl Schreiber 2014.12.08 15:28  

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!!

Winsor Hoang
4743
Winsor Hoang 2014.12.08 22:22  
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. 
/
To add comments, please log in or register