You are assuming that OnTick will be called for the symbol irrespective of the symbol selected, but unfortunately for your EA code, its OnTick() event handler is only called when a new tick arrives for that chart's symbol on which the EA is placed and not the symbol select by the EA.
If the chart on which the EA is running receives a low frequency of ticks or no ticks at all during the period that the symbol selected for the EA has a higher frequency of tick activity, then the EA will not process the data in a timely fashion.
If your intention is only to trade one symbol per EA, then place the EA on the Chart with the symbol (without the user having to select the symbol via the EA). This will be the most efficient way.
The only reason to use such a setup (as your example), is if your EA is trading multiple symbols at the same time, and for those cases only, the recommended solution is as follows:
- Place the EA always on a symbol with the highest tick frequency possible (to maximise the OnTick call frequency).
- Supplement the OnTick() event activity, with OnTimer() events at a reasonable frequency to compensate when tick activity is low.
EDIT: Alternatively, only use the OnTimer() event without the OnTick() event and process data at a regular interval (aka "heart-beat"), for example if you are only processing data on the bar's opening.
You are assuming that OnTick will be called for the symbol irrespective of the symbol selected, but unfortunately for your EA code, its OnTick() event handler is only called when a new tick arrives for that chart's symbol on which the EA is placed and not the symbol select by the EA.
If the chart on which the EA is running receives a low frequency of ticks or no ticks at all during the period that the symbol selected for the EA has a higher frequency of tick activity, then the EA will not process the data in a timely fashion.
If your intention is only to trade one symbol per EA, then place the EA on the Chart with the symbol (without the user having to select the symbol via the EA). This will be the most efficient way.
The only reason to use such a setup (as your example), is if your EA is trading multiple symbols at the same time, and for those cases only, the recommended solution is as follows:
- Place the EA always on a symbol with the highest tick frequency possible (to maximise the OnTick call frequency).
- Supplement the OnTick() event activity, with OnTimer() events at a reasonable frequency to compensate when tick activity is low.
EDIT: Alternatively, only use the OnTimer() event without the OnTick() event and process data at a regular interval (aka "heart-beat"), for example if you are only processing data on the bar's opening.
Hi Fernando,
Thanks for your response.
Yes so my idea would be to use the one EA to trade multiple symbols at the same time by selecting which symbols to trade within the EA settings. This way i could trade multiple trading strategies on different pairs with minimal charts open.
Good advice about the OnTick potential issues - I hadn't thought of that. I will look into the OnTimer events to try and improve the timing of the EA!.
Thanks again
Copy and paste can save a lot of time, but it can also lead to many problems when you don't check it carefully.
if(OrdersTotal()==0 && EntryCriteria(symbol) == "Buy") OrderSend(symbol, OP_SELL, 0.10, SymbolInfoDouble(symbol,SYMBOL_BID), 3, SymbolInfoDouble(symbol,SYMBOL_ASK) + (10 * Pips(symbol)), SymbolInfoDouble(symbol,SYMBOL_BID) - (50 * Pips(symbol)), "Test", 0, 0, clrNONE);
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Hi all,
I wonder if someone can shed light on the possible disadvantages of using an EA on one chart to manage a portfolio of instruments.
Attached is a basic EA which allows the user to select which pairs they want to trade, and the EA will then trade the portfolio regardless of which chart the EA is initialized on.
What are your thoughts?
arrays could act better in my opinion
Copy and paste can save a lot of time, but it can also lead to many problems when you don't check it carefully.
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
Thanks Keith!
Well spotted - it was just a quick example put together rather than an EA I plan to use!
Ah okay, thanks for moving it to the correct topic; I will be sure to post in the correct section in future.
arrays could act better in my opinion
Yes that would work much better for a larger choice of instruments! Thanks!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
I wonder if someone can shed light on the possible disadvantages of using an EA on one chart to manage a portfolio of instruments.
Attached is a basic EA which allows the user to select which pairs they want to trade, and the EA will then trade the portfolio regardless of which chart the EA is initialized on.
What are your thoughts?