# Magic Number - Is there any use?

5485

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?

Moderator
97588

933

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)
{

}
}

&& 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)
{

}
}```
Moderator
32824

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?

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

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.
5485

it is so confusing