## Magic Number question (trying to learn coding)

Moderators: xard777, mrtools, Banzai

### Magic Number question (trying to learn coding)

#1
Hi everyone,

I'm trying to understand how to use Magic Numbers to separate my trades. I scalp as well as have trend trades open with different Stop Loss and Take Profit settings and different indicators.

The current EA I have sets the Stop Loss for every chart I open regardless of the time frame. Of course this doesn't work for me as a 10 pip Stop Loss on a D1 chart is useless.

I'm trying to understand how to use Magic Numbers so I can both scalp and trend trade at the same time.

If I understand it correctly, this is an example of how I would do it:

Set my scalping EA on the M5 EUR/USD chart with a Stop Loss of 10. Magic Number = 11.

Set my trend EA on the D1 EUR/USD chart with a Stop Loss of 150. Magic Number = 99.

Questions:

1) Is this example correct?

2) The EA's will not interfere with each other, right? For example, the scalp EA won't change my Stop Loss on the trend chart or vice versa.

3) If I want to trade another pair (say AUD/NZD), would I put the EA I want (scalp or trade) on the AUD/NZD chart and assign a different Magic Number?

i.e. Scalp EA on AUD/NZD = 12, Trend EA = 98

OR

Could I keep the same Magic Number?

In which case the scalp EA will set my Stop Loss to 10 on every chart it is on and the trend EA will set my Stop Loss to 150 on every chart it is on.

That means the appropriate EA would have to be put on every chart I open.

Is this correct?

TIA for your help understanding this stuff.
Terry

### Re: Magic Number question (trying to learn coding)

#2
61 views and nobody can help me with this question?
Terry

### Re: Magic Number question (trying to learn coding)

#3
In2Blues wrote:
Mon Oct 05, 2020 9:31 am
Hi everyone,

I'm trying to understand how to use Magic Numbers to separate my trades. I scalp as well as have trend trades open with different Stop Loss and Take Profit settings and different indicators.

The current EA I have sets the Stop Loss for every chart I open regardless of the time frame. Of course this doesn't work for me as a 10 pip Stop Loss on a D1 chart is useless.

I'm trying to understand how to use Magic Numbers so I can both scalp and trend trade at the same time.

If I understand it correctly, this is an example of how I would do it:

Set my scalping EA on the M5 EUR/USD chart with a Stop Loss of 10. Magic Number = 11.

Set my trend EA on the D1 EUR/USD chart with a Stop Loss of 150. Magic Number = 99.

Questions:

1) Is this example correct?

2) The EA's will not interfere with each other, right? For example, the scalp EA won't change my Stop Loss on the trend chart or vice versa.

3) If I want to trade another pair (say AUD/NZD), would I put the EA I want (scalp or trade) on the AUD/NZD chart and assign a different Magic Number?

i.e. Scalp EA on AUD/NZD = 12, Trend EA = 98

OR

Could I keep the same Magic Number?

In which case the scalp EA will set my Stop Loss to 10 on every chart it is on and the trend EA will set my Stop Loss to 150 on every chart it is on.

That means the appropriate EA would have to be put on every chart I open.

Is this correct?

TIA for your help understanding this stuff.
Hey Terry,
Your current understanding of 'Magic Number' is correct and should work as you stated for question 1,2 and 3.
However, you have not provided detail on how the EA manages trades. eg. Does it check magic number / symbol when it modifies or closes trades.
So depending how it was coded, it may be something you will need to watch for in order to understand. Most single-pair EA's would be coded to check for their symbol and magic number to modify/ close trades that I have encountered and make sure to code myself.

Best think to do is test both cases out for yourself and find your own answer as others can't do much to help without using your same EA
Hope that helps ^_^

### Re: Magic Number question (trying to learn coding)

#4
Thanks for your help Tzamo. I'm working on a number of things right now (probably too many lol) but will test to see how it handles things.
Terry

1. ### Similar Topics

1. #### Learn to code questions

1 Replies 624 Views

by society, Sun Jun 09, 2019 3:07 am in Coding Help

1 Replies
624 Views
2. #### Indicator buffer number

0 Replies 715 Views

by blackice, Wed Apr 17, 2019 11:30 pm in MT4 Indicators

0 Replies
715 Views