Usefulness (or not) of the magic number with MQL5.

 

Due to new position system in MT5 (compared to orders in MT4),
do you see any usage for MAGIC number?

How would you use it?


You can find some interesting discussion in this topic, we can formulate the following conclusions :

  • Magic number can be used to distinguish trades from different EA also with MT5. Ubzen gives some good examples.
  • Position centric architecture of MT5 makes things more difficult that with MT4, but remains certainly possible.
  • We have to check that it is useful to solve this issue (running several EA on the same symbol/account) rather than running each EA on a separate account.
 

just some threads about it :

and this article Orders, Positions and Deals in MetaTrader 5 where all the samples are having magic number.


 

Thanks Sergey newdigital,

but the question is why to use it?

Magic number was used to differentiate the issuer of order, but here we have a single position.
So you cannot use two trading systems on same instrument, so why to use them then? 

 
graziani:

Thanks Sergey,

but the question is why to use it?

Magic number was used to differentiate the issuer of order, but here we have a single position.
So you cannot use two trading systems on same instrument, so why to use them then

You can use two (or more) trading systems on same instrument, this is precisely why you need magic number. Now the question is how .
 

I do not know about it ... all as I know that MT5 EAs are having magic numbers anyway - example with free EAs:

============

1. First version of AsctrendND EA

2. Next version of AsctrendND EA (verion 1.02) with TrendStrength filter added.

3. Latest version of the system with latest EAs to download

4. 2stochm_v4 EA is on this post.

5. Scalp_net trading system

  • template/indicators and how to use are on this comment.
  • scalp_net_v132_tf EA is on this post with optimization results/settings for EURUSD M5 timeframe
  • possible settings #1 for this EA for EURUSD M5 timeframe with backtesting results is on this post.

============

So, those EAs are having magic numbers. Why? This is small article about it : Orders, Positions and Deals in MetaTrader 5 and all the samples on this article are having magic mumber so ...

 
newdigital:

I do not know about it ... all as I know that MT5 EAs are having magic numbers anyway - example with free EAs:

============

1. First version of AsctrendND EA

2. Next version of AsctrendND EA (verion 1.02) with TrendStrength filter added.

3. Latest version of the system with latest EAs to download

4. 2stochm_v4 EA is on this post.

5. Scalp_net trading system

  • template/indicators and how to use are on this comment.
  • scalp_net_v132_tf EA is on this post with optimization results/settings for EURUSD M5 timeframe
  • possible settings #1 for this EA for EURUSD M5 timeframe with backtesting results is on this post.

============

So, those EAs are having magic numbers. Why? This is small article about it : Orders, Positions and Deals in MetaTrader 5 and all the samples are having magic mumber so ...

Sergey newdigital, I already said to you the AscTrendND EA CAN'T be used simultaneously with other EA or manual trade. I used magic number, but at the time I program this EA, I don't understand very well how to use it, and I don't use it the right way.

I don't know about others EA.

 
angevoyageur:

Sergey newdigital, I already said to you the AscTrendND EA CAN'T be used simultaneously with other EA or manual trade. I used magic number, but at the time I program this EA, I don't understand very well how to use it, and I don't use it the right way.

I don't know about others EA.

I am newdigital here ... I am Sergey in my real life inside my country :) and this is great difference ... if you meet me in your country as a tourist so you will meet russian Sergey (you will not meet newdigital) :)

To say seriously - I just replied about magic number on the way I could ...

 
newdigital:

I am newdigital here ... I am Sergey in my real life inside my country :) and this is great difference ... if you meet me in your country as a tourist so you will meet russian Sergey (you will not meet newdigital) :)

To say seriously - I just replied about magic number on the way I could ...

Ok I do not know what you wrote here was not part of your real life. I don't do it any more.
 
The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument
The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument
  • 2010.07.20
  • Nikolay Demko
  • www.mql5.com
This article considers the questions of information coding, using the magic-identification, as well as the division, assembly, and synchronization of automatic trading of different Expert Advisors. This article will be interesting to beginners, as well as to more experienced traders, because it tackles the question of virtual positions, which can be useful in the implementation of complex systems of synchronization of Expert Advisors and various strategies.
 
angevoyageur:
You can use two (or more) trading systems on same instrument, this is precisely why you need magic number. Now the question is how .

https://www.mql5.com/en/articles/112 also claims what you have said:

And so let us sum up what we have: what opportunities are we laying down into the system:

  1. The possibility of two or more Expert Advisors to work on a single instrument and not interfere.
  2. The possibility of two or more Expert Advisors to work on different instruments and complement each other.
  3. The ability to identify the order by the instrument, working with the Expert Advisor.

But i have to disagree completely with this. There is no way you can write two systems that are going to exploit the same instrument. If you have a system that is trying to control a non-stationary stochastic process, by introducing another system that trys to work simultaneously with yours, by excluding of each other, you are completely negating the systems itselfs, as you are changing the domain of input data and events of systems in use.

The only way to have to systems working on same instrument is by using VOM (Virtual Order Management).

And the main problem with this is that you are completely unnecessary using time and effort to achieve something that can be solved in a simple way,
and that is to have two accounts (thereby using more resources of course).

So by  introducing a single position system in MT5, MQ are forcing everyone to use either more resources or more time and effort to implement a solution that is going to be less reliable than same solution on MT4.

Magic can perhaps be used in MT5, but using it is pure idiotism. 

The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument
The Use of ORDER_MAGIC for Trading with Different Expert Advisors on a Single Instrument
  • 2010.07.20
  • Nikolay Demko
  • www.mql5.com
This article considers the questions of information coding, using the magic-identification, as well as the division, assembly, and synchronization of automatic trading of different Expert Advisors. This article will be interesting to beginners, as well as to more experienced traders, because it tackles the question of virtual positions, which can be useful in the implementation of complex systems of synchronization of Expert Advisors and various strategies.
 
graziani:

https://www.mql5.com/en/articles/112 also claims what you have said:

But i have to disagree completely with this. There is no way you can write two systems that are going to exploit the same instrument. If you have a system that is trying to control a non-stationary stochastic process, by introducing another system that trys to work simultaneously with yours, by excluding of each other, you are completely negating the systems itselfs, as you are changing the domain of input data and events of systems in use.

The only way to have to systems working on same instrument is by using VOM (Virtual Order Management).

And the main problem with this is that you are completely unnecessary using time and effort to achieve something that can be solved in a simple way,
and that is to have two accounts (thereby using more resources of course).

So by  introducing a single position system in MT5, MQ are forcing everyone to use either more resources or more time and effort to implement a solution that is going to be less reliable than same solution on MT4.

Magic can perhaps be used in MT5, but using it is pure idiotism. 

I don't understand your argumentation. You said 'no way' and then 'the only way', this is a contradiction. In general MQL5 is more difficult to master, and a lot of thing can be done more easily with MT4. I don't think anyone would argue about that. Against that mql5 brings to us a lot of new possibilities. But your starting question was "how" and "why" using magic number with mql5.

Why : the answer is the same a mql4. To use more than 1 EA with the same instrument.

How : it's another matter. VOM is an example, it has some limitation but it works, not ?

I don't see (or understand) any solid argument to prove that "using magic in mql5 is a pure idiotism". If you are right, I would like to understand.