Apply Same EA with different parameters to multiple charts in one Go

Hi All,

I am operating on several crosses and for each one I would need to apply the same EA but with different parameters e.g. for Cross EURUSD the variable leverage is 1, while for USDCAD is 2, for CHFJPY 3 etc

I can certainly do it manually although this is quite repetitive and time consuming.

Is there a way to create a script/EA that will apply the aforementioned EA to multiple chart in just one go?

I have found somewhere else that I could use the ChartApplyTemplate function, however this will call a template where the EA variables are already set. One way could be to create different templates for different crosses just once. This is better than doing it all the time, but is there a faster solution?

Thanks,

MG

I don’t understand what you’re trying to do, but yes it is possible to work with multiple pairs in one EA. Can you explain what you exactly want to do and I’ll explain how to do it.

Hi ChesterJohn,

Thanks for the fast reply. I am actually not trying to fit multiple pairs in one EA, but I’d rather want to apply the same EA to different Charts through a script.

Basically what I am trying to do is to attach an EA to different charts in one go. The EA has some input variables. For these variable the value that needs to be input depend on the symbol of the chart.

Now I am attaching this EA to each chart manually, changing the input variables according to the symbol, but it’s quite tedious and time consuming considering that I am doing it for 10+ crosses;)

e.g. Assume you have one EA with one input variable (e.g. leverage) and this variable should have a different input depending on the pair showed on the chart (i.e. 1 for EURUSD, 2 for AUDUSD etc).
You can open the EURUSD chart, attach the EA with the variable set to 1, then open the AUDUSD chart and set the variable for this pair to 2 etc.
I’d like to have a script that does it for me. I have actually just tried with the function ChartApplyTemplate() and it works;) The only drawback is that I have to create different template for each cross and specify the variable of the input variable in each template. Doable, faster, but if there is anything even less time consuming that would be great;)

Let me know if you can help,
Thanks,
MG

The way I’d do this is to create a default template with the EA on a chart. Then inside the EA, code the parameters to be loaded depending on what they symbol is. I forget the syntax for everything because I’m not on a computer with trading software right now, but something along the lines of:

if(symbol() == “EURUSD”)
Parameter = 1;
else if (symbol() == “GBPJPY”)
Parameter = 2;

etc

When you open a new chart, it applies the default template, so it is literally just a case of opening the chart.
Hope that’s what you mean…

1 Like

Hey Thanks!!!

I like this approach. That would basically mean to delete the input variable and bring them into the code as global variable which is not a big deal.

Instead of the IF operator I am trying to use the SWITCH operator, but this does not seem to be working as SWITCH cases just use integer and the symbol is a string…I guess I will stick with a series of IF as you suggested.

Thanks a lot. This was very helpful
MG

There are other ways to do this so you can make it a manually applied parameter or a default one based on the symbol. That way you have more flexibility. If you want me to explain, pm me or ask on here and I’ll explain. Also, if you want to share what your EA is doing, I’d be interested to know :slight_smile: