In what circumstance do you believe its necessary to use a dynamic(ever changing) and automatic(not user chosen) magicnumber?

 
  • 62% (25)
  • 38% (15)
Total voters: 40
 
For the kind of trading and expert that I need, I don't need to touch the magic number
 
Its necessary if there are >2 EA work at the same time.
 
rockyhoangdn:
Its necessary if there are >2 EA work at the same time.
on the same symbol.
 

The situation i met was in mt4 but i posted here because i believe the same would apply in both and besides mql4 has no polls feature. The code i used as an antidote is also mt4 but i wont post it here me i dont want trouble here anymore <edited by moderator>. But ill just explain because its nothing complex.

 So the situation was you want to open a trade and automatically sub trades and sub sub trades and sub sub sub... will open later on with the possibility of opening another master trade without the ea confusing the generations of one master trade from the other. In order to run only one instance of the EA, a normal user set magic number would not work.

 The simple solution I discovered was to use TimeCurrent() as magic number and all generations of a particular master trade would use the master's magic number(which is timecurrent() at the time the master opened its like the way a sir name is passed down from grand parents. So for parent trade the magic is simply TimeCurrent() but for sub trades a complex system in a Open trades cycle would have to be developed where by if an open trade is selected, then its magic number is saved in a variable and passed down to any sub trades that open in the loop and also to later on operate on sub trades or sub trades from sub trades even if the master trade is no longer there because it would have left the "sir name" to the remaining trades. While this continues its possible for the EA to again open a trade with a new "sir name" that will itself again form its own generation of trades while the EA would still manage all trades without conflict. This is simply done when a trade is selected with a certain "sir name" and all trades with that "sir name" are checked/modified/deleted and so forth before another "sir name" is selected. Its called showing them how its done. 

 

Dynamic in a sense is necessary when you use the same EA ... let the EA XYZ on the same currency with different time frames.

For example one want to use EA XYZ on EURUSD M1, M5, M15, M30 and H1 .. and want that one EA have to do nothing with the orders of the same EA on other time frame.

The best practice is to use MagicNumber as

MagicNumber + Period() ... So let say your MagicNumber is 123 ... then the actual MagicNumber for different TimeFrames with this formula would be:

M1 Magic = 123 + 1 = 124

M5 Magic = 123 + 5 = 128

M15 Magic = 123 + 15 = 138

and so on ..

Hope it will help

 
bachapk:

Dynamic in a sense is necessary when you use the same EA ... let the EA XYZ on the same currency with different time frames.

For example one want to use EA XYZ on EURUSD M1, M5, M15, M30 and H1 .. and want that one EA have to do nothing with the orders of the same EA on other time frame.

The best practice is to use MagicNumber as

MagicNumber + Period() ... So let say your MagicNumber is 123 ... then the actual MagicNumber for different TimeFrames with this formula would be:

M1 Magic = 123 + 1 = 124

M5 Magic = 123 + 5 = 128

M15 Magic = 123 + 15 = 138

and so on ..

Hope it will help


This will still require external input. You can fully automate it and dynamise it such that the ea can only be attached once and manage all trades irrespective of timeframe so that the user only attaches it without worrying about magic number.
 
tonny:

This will still require external input. You can fully automate it and dynamise it such that the ea can only be attached once and manage all trades irrespective of timeframe so that the user only attaches it without worrying about magic number.
Remove extern from MagicNumber :D
Reason: