I programmed a very neat EA that works well an a couple of pairs. Now instead of pulling it onto every chart I would like to have one EA run and handle multiple pairs at the same time. So far so good but there is one remaining issue that I have: In the documentation about getting values from indicators (iCustom, iMA, ...) all the examples are always so that you define a global int variable. For example:
Now, how can I call the indicator with a different pair as an argument every time I iterate over the list of symbols? I think the way that I am doing now, I cannot do that since the indicator handle is just an int variable and not a funciton. So, is the solution to define a function with the symbol as an input argument and it creates a new handle every time it gets called? Is that how one would do that?
Or would I rather create as many indicator handles for each indicator as I have symbols to trade?
Bit lost here. Thanks for any help! Let me know if you need more code, I just thought I keep it as simple as possible since I am more asking for the general concept rather than actual code.
In OnOnit (), you must create indicator handles for the required symbols in advance. For example for EURSD, H1 and USDJPY, H1.
And then, in OnTick (), using CopyBuffer, get the indicator values.
The main thing: in MQL5, the indicator handle MUST BE CREATED ONCE - and this is done in OnInit.
I programmed a very neat EA that works well an a couple of pairs. Now instead of pulling it onto every chart I would like to have one EA run and handle multiple pairs at the same time. So far so good but there is one remaining issue that I have: In the documentation about getting values from indicators (iCustom, iMA, ...) all the examples are always so that you define a global int variable. For example:
Now, how can I call the indicator with a different pair as an argument every time I iterate over the list of symbols? I think the way that I am doing now, I cannot do that since the indicator handle is just an int variable and not a funciton. So, is the solution to define a function with the symbol as an input argument and it creates a new handle every time it gets called? Is that how one would do that?
Or would I rather create as many indicator handles for each indicator as I have symbols to trade?
Bit lost here. Thanks for any help! Let me know if you need more code, I just thought I keep it as simple as possible since I am more asking for the general concept rather than actual code.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I programmed a very neat EA that works well an a couple of pairs. Now instead of pulling it onto every chart I would like to have one EA run and handle multiple pairs at the same time. So far so good but there is one remaining issue that I have: In the documentation about getting values from indicators (iCustom, iMA, ...) all the examples are always so that you define a global int variable. For example:
Now, how can I call the indicator with a different pair as an argument every time I iterate over the list of symbols? I think the way that I am doing now, I cannot do that since the indicator handle is just an int variable and not a funciton. So, is the solution to define a function with the symbol as an input argument and it creates a new handle every time it gets called? Is that how one would do that?
Or would I rather create as many indicator handles for each indicator as I have symbols to trade?
Bit lost here. Thanks for any help! Let me know if you need more code, I just thought I keep it as simple as possible since I am more asking for the general concept rather than actual code.