Multiple EA, multiple MetaTrader and Multiple chart...

 

Hi all,

I need some information:

  • If I have one metatrader client terminal e 2 chart (Eurusd and UsdChf)
  • is it possibile attach the same EA on 2 chart?
  • One tick arrives on first chart (Eurusd) and, after a few milliseconds, a tick arrives on the second chart (UsdChf). If the tick on second chart arrives when the EA on first chart is running, The EA on the second chart does not "see" the tick or also the second EA runs concurrently with the first?
  • If I want open more concurrently metatrader client terminal session what should I do? Install, with the same metatrader setup, on different folder (C:\program\mt_1, C:\program\mt_2...)?

Thanks

 

David -

You can attach the same EA on more than one chart. Each EA will be triggered with the incoming tick on the chart on which it's attached independent of ticks on other charts. The only conflict I'm aware of is that two EA's may not execute trades simultaneously. For solutions, click here:

https://www.mql5.com/en/articles/1412

 

Almost it works, no problems in attaching the same EA on multiple charts, it depend on the EA itself, mean if the EA uses Symbol name or magic numbers in its orders,

second there is no problem setup the same MT4 in different directories.

 
Change the magic number (one of the EAs variables) so each EA only handles its own trades.
 
davidze:
  • If I want open more concurrently metatrader client terminal session what should I do? Install, with the same metatrader setup, on different folder (C:\program\mt_1, C:\program\mt_2...)?

Yeah, or u can just copy MT4 folder contents to another folder (no need to re-install). Note that if u log on to the same account from 2 different Terminals and run an EA on each, u still need them to have different magic numbers (assuming they are designed to use magic numbers in a multi-EA environment). In this case they would have no problem interacting with the server at the SAME time (opening orders, closing orders, etc.) .

 

Thanks all for answer.

To better understand I need more information.

If I use one metatrade client terminal and two charts with different Symbol If I copy the same EA twice and name the first one EAEurUsd and the second one EAUsdChf and attach the first to EurUsd chart and the second to UsdChf chart

  • I need magic number or two Ea work separately?
  • I can place on market two contemporary orders or the second attempt order "see" the server is busy?

Thanks

 
davidze:

Thanks all for answer.

To better understand I need more information.

If I use one metatrade client terminal and two charts with different Symbol If I copy the same EA twice and name the first one EAEurUsd and the second one EAUsdChf and attach the first to EurUsd chart and the second to UsdChf chart

  • I need magic number or two Ea work separately?
  • I can place on market two contemporary orders or the second attempt order "see" the server is busy?

Thanks

You don't need to rename the EAs.


Regarding the use of magic numbers. If you can answer yes to all of the following:

- you have the EA attached to different pairs

- the EA only deals in orders for the native pair of the chart on which it has been attached

- no other EAs are dealing in orders for these pairs under the same account number

then you don't need to implement magic numbers and your EA may check for its own orders by simply checking that OrderSymbol() == Symbol().


Regarding your need to handle the potential for "Trade Context Busy":

In the above implementation, yes, you WILL need to handle this scenario. The reason is that each instance of the terminal represents a single Trade Context. Therefore, EAs will contend for use of this Trade Context (for TRADING functions only) and conflict is obviously more likely to happen when 2 EAs behave in a similar manner. You are implementing exactly the same EA on both charts, so on the surface, it would seem likely that they may both attempt to execute trading functions at the same time. However, due to their use on different pairs, or due to some parameters on your EAs, this may not be the case. Only you can tell. Bottom line - if you are running multiple EAs in the same terminal instance, then code in the logic to detect and handle Trade Context Busy properly.


CB.

 

Thanks cloudbreaker.

I can answer yes to all your question.


Last question: If I use 2 different terminal on two different chart (with same login broker account) I don't worry for "Trade Context Busy" because I can place market order at the same time? Is it correct?


Thankyou

 
davidze:

Thanks cloudbreaker.

I can answer yes to all your question.


Last question: If I use 2 different terminal on two different chart (with same login broker account) I don't worry for "Trade Context Busy" because I can place market order at the same time? Is it correct?


Thankyou

That is correct.


CB

 

Hi,

Does this scenario also mean that the use of magic numbers is not required since each EA attached to a different currency chart on different MT4 Terminals will only open and close trades according to their native Symbol() they are attached to?

 
mindreality:

Hi,

Does this scenario also mean that the use of magic numbers is not required since each EA attached to a different currency chart on different MT4 Terminals will only open and close trades according to their native Symbol() they are attached to?

Read CB's first answer in this thread.

Reason: