This solution gives me "indicator is too slow" error, especially when symbolsList contains 4+ symbols. I doubt that the problem is caused due to lack of resources, the computer I'm running this on has the following specs:
CPU: Xeon EP-2699 QuadCore @ 2.2 GHz
16 GB RAM
All other applications are closed and Metatrader is the only application running.
Any suggestions?
Thanks
You are on the right track but missing the prize.
The agent is already aware of a new tick and it's value as that is what triggers it to send the event. So just send the new tick value with the event notification, this will save you looking up the new price in the EA when it has already been delivered to the terminal once.
I need an EA that can track multiple symbols' prices (around 10) , and open/close positions when certain prices meet certain conditions.
I know that if the EA is attached to one symbol, then the OnTick() function will notify the EA when the bid/ask price of the symbol changes. I basically need the EA to get notified when the price of any of the symbols I'm tracking changes, with minimum delay of course. I am not interested in past prices and history data, only the current bid/ask prices.
At first my approach was to set a timer to tick every 1 millisecond using:
And then in the OnTimer function I get the tick for ALL the symbols I'm tracking and store bid/ask values in corresponding arrays:
The problem with this approach is that:
1) As described in MQL documentation, even when you pass 1 to EventSetMillisecondTimer, it still does not call onTimer every 1 ms, because of software limitation. Based on my tests, EventSetMillisecondTimer(1) calls OnTimer every ~15 ms on average. That means if a symbol changes its price shortly after OnTimer is called, the EA will not get notified of the price change and will need to wait around 15 ms for the next OnTimer call to fetch the new prices. Although 15 ms does not sound like a long time, I'm modelling an HFT EA, so it is a big problem.
2) With this approach, every time OnTimer is called, ALL symbols prices are fetched, even those who have not had a price change since the last OnTimer call. This is inefficient for the purpose of HFT.
---
I then saw this comment, and therefore I implemented the following solution (this is the solution that gives me "indicator is too slow" error").
EA Code:
Indicator code (TickTracker.mq5):
This solution gives me "indicator is too slow" error, especially when symbolsList contains 4+ symbols. I doubt that the problem is caused due to lack of resources, the computer I'm running this on has the following specs:
CPU: Xeon EP-2699 QuadCore @ 2.2 GHz
16 GB RAM
All other applications are closed and Metatrader is the only application running.
Any suggestions?
Thanks
Did you solved? I have the same problem
So stop polling and get called only when a price changes.
The Implementation of a Multi-currency Mode in MetaTrader 5 - MQL5 Articles (2011)
- 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 need an EA that can track multiple symbols' prices (around 10) , and open/close positions when certain prices meet certain conditions.
I know that if the EA is attached to one symbol, then the OnTick() function will notify the EA when the bid/ask price of the symbol changes. I basically need the EA to get notified when the price of any of the symbols I'm tracking changes, with minimum delay of course. I am not interested in past prices and history data, only the current bid/ask prices.
At first my approach was to set a timer to tick every 1 millisecond using:
And then in the OnTimer function I get the tick for ALL the symbols I'm tracking and store bid/ask values in corresponding arrays:
The problem with this approach is that:
1) As described in MQL documentation, even when you pass 1 to EventSetMillisecondTimer, it still does not call onTimer every 1 ms, because of software limitation. Based on my tests, EventSetMillisecondTimer(1) calls OnTimer every ~15 ms on average. That means if a symbol changes its price shortly after OnTimer is called, the EA will not get notified of the price change and will need to wait around 15 ms for the next OnTimer call to fetch the new prices. Although 15 ms does not sound like a long time, I'm modelling an HFT EA, so it is a big problem.
2) With this approach, every time OnTimer is called, ALL symbols prices are fetched, even those who have not had a price change since the last OnTimer call. This is inefficient for the purpose of HFT.
---
I then saw this comment, and therefore I implemented the following solution (this is the solution that gives me "indicator is too slow" error").
EA Code:
Indicator code (TickTracker.mq5):
This solution gives me "indicator is too slow" error, especially when symbolsList contains 4+ symbols. I doubt that the problem is caused due to lack of resources, the computer I'm running this on has the following specs:
CPU: Xeon EP-2699 QuadCore @ 2.2 GHz
16 GB RAM
All other applications are closed and Metatrader is the only application running.
Any suggestions?
Thanks