Download MetaTrader 5

Magic Number - Is there any use?

To add comments, please log in or register
Dua Yong Rew
5485
Dua Yong Rew  

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
97588
Sergey Golubev  
Just found small thread about it : Magic numbers
Shaharudin Ahmad
933
Shaharudin Ahmad  
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
32824
Alain Verleyen  
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
5485
Dua Yong Rew  
it is so confusing
To add comments, please log in or register