Download MetaTrader 5

Magic Number - Is there any use?

To add comments, please log in or register
Do you want to learn MQL5? 300 articles will help you!
Dua Yong Rew
5423
Dua Yong Rew 2013.11.29 07:04 

In MT4, using magic can sort out which position is sent by which EA and managed independently.

But in MT5, all are merged into one position so is there any use for magic number? 

Sergey Golubev
Moderator
93777
Sergey Golubev 2013.11.29 07:20  
Just found small thread about it : Magic numbers
Shaharudin Ahmad
914
Shaharudin Ahmad 2013.11.29 07:44  
doshur:

In MT4, using magic can sort out which position is sent by which EA and managed independently.

But in MT5, all are merged into one position so is there any use for magic number? 

MT5 : I usually use magic number to diff the position of order. example : diff lot or detect diff negative value of profit.
      if(  PositionSelect("EURCHF")==true &&PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY
            
            && PositionGetInteger(POSITION_MAGIC)==123231
            && PositionGetDouble(POSITION_VOLUME)==loturus+2
        
            )
                {
               double asalz2 = PositionGetDouble(POSITION_PRICE_OPEN);
               double currentz2 = PositionGetDouble(POSITION_PRICE_CURRENT);
               if(asalz2-currentz2>300*Poin) 
             {
                   
                   fBuyL3();
             }
             }

        if(  PositionSelect("EURCHF")==true &&PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY
            
            && PositionGetInteger(POSITION_MAGIC)==878763
            && PositionGetDouble(POSITION_VOLUME)==loturus+3
          
            )
                 {
               double asalz3 = PositionGetDouble(POSITION_PRICE_OPEN);
               double currentz3 = PositionGetDouble(POSITION_PRICE_CURRENT);
               if(asalz3-currentz3>300*Poin)   
             {
                   
                   fBuyL4();
             }
             }
Alain Verleyen
Moderator
30755
Alain Verleyen 2013.11.29 08:09  
doshur:

In MT4, using magic can sort out which position is sent by which EA and managed independently.

But in MT5, all are merged into one position so is there any use for magic number? 


https://www.mql5.com/en/forum/15482

The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument

The Optimal Method for Calculation of Total Position Volume by Specified Magic Number

Usefulness (or not) of the magic number with MQL5.
Usefulness (or not) of the magic number with MQL5.
  • www.mql5.com
Magic number can be used to distinguish trades from different EA also with MT5.
Dua Yong Rew
5423
Dua Yong Rew 2013.11.29 13:26  
it is so confusing
To add comments, please log in or register