Does CExpert handles all open orders without checking magic_number?

 

Hi, while building my robot I looked into the CExpert class.

I see the Symbol-Check but there is no check for the magic_number.

What am I missing ? (the Expert should only handle its own orders right?)

bool CExpert::Processing(void)
{
   . . .
   
   //--- check if plased pending orders
   int total=OrdersTotal();
   if(total!=0)
   {
      for(int i=total-1; i>=0; i--)
      {
         m_order.SelectByIndex(i);
      
         if(m_order.Symbol() != m_symbol.Name()) // NO MAGIC NUMBER CHECK ??
            continue;
         
         . . . 
      } 
   }
}


thanks 


Robert

 
Robert:

Hi, while building my robot I looked into the CExpert class.

I see the Symbol-Check but there is no check for the magic_number.

What am I missing ? (the Expert should only handle its own orders right?)


thanks 


Robert

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>

CPositionInfo  m_position;                   
CTrade         m_trade;   
void OnTick()
  {

   for(int i=PositionsTotal()-1; i>=0; i--)
      if(m_position.SelectByIndex(i))
        {
         Print("Magic Number ",m_position.Magic());


        }
  }


        }
  }
 
Robert:

Hi, while building my robot I looked into the CExpert class.

I see the Symbol-Check but there is no check for the magic_number.

What am I missing ? (the Expert should only handle its own orders right?)




Whtn you instantiate Ctrade, you can set some parameters to it:

CTrade         m_trade;   

m_trade.SetExpertMagicNumber(Magic1);
m_trade.SetDeviationInPoints(m_slippage);


It depends on how you code your EA.. there are other ways too. 


You can also take a look at public functions on Trade.mqh. line 91 is about SetExpertMagic..  

\Include\Trade\Trade.mqh

 
rrocchi:



Whtn you instantiate Ctrade, you can set some parameters to it:


It depends on how you code your EA.. there are other ways too. 


You can also take a look at public functions on Trade.mqh. line 91 is about SetExpertMagic..  

\Include\Trade\Trade.mqh

He wants to find the magic number on open market orders. Do not set the magic number before the order you have written is opened. "m_trade.SetExpertMagicNumber(Magic1);" it won't do any good.

 
rrocchi:



Whtn you instantiate Ctrade, you can set some parameters to it:


It depends on how you code your EA.. there are other ways too. 


You can also take a look at public functions on Trade.mqh. line 91 is about SetExpertMagic..  

\Include\Trade\Trade.mqh


Thank you rrochi, I can see now also in CExpert class.


void CExpert::Magic(ulong value)
  {
   if(m_trade!=NULL)
      m_trade.SetExpertMagicNumber(value);
. . .
. . .
Reason: