Hi
Normally, you can't get an EA to tell when the price data is stopped until after it starts again. This is because EAs run when the terminal receives a tick and no price data means no ticks, which means the EA doesn't run, so it can't do anything. One exception is to write your EA so it runs in a continuous loop, refreshing data within it, but I think this practice is unwise.
You will never be able to trade with price data many seconds old unless you have large delays in your EA because the EA runs as soon as the tick is received and with the tick comes new data.
If it is helpful, you could record the time of the previous tick in a variable and compare it with the current time. This allows you to monitor data stoppages.
Cheers
Jellybean
- 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 sometimes see that the price feed from a broker has stopped, only to resume a while later. Just in the last hour I saw that the price froze for around 6 minutes, base on the time in the MarketWatch pane. It's a demo account, and I presume that brokers may not worry as much as with live servers when doing maintenance, so may reboot the demo server any time they want. If it was a live account in which I saw the 6 minute price freeze then I'd seriously consider withdrawing my money from them and trading elsewhere.
I was running my Expert Advisor in which IsConnected() and IsTradeAllowed() is continuously called in an independent infinite loop and prints an error message when either returns false. But in the last price feed freeze no message was printed. So it seems that IsConnected() and IsTradeAllowed() aren't foolproof in detecting such a problem. There weren't any messages in the Experts log or Journal either. So if I wasn't at my computer watching the terminal then I would never have known of the price feed freeze. This would be quite worrying when letting an EA trade with real money.
I was actually running two terminals at the same broker and both had the price feed freeze at exactly the same times. The terminals are running on a VPS (that costs 89.95 USD per month), so I was watching through a Windows Remote Desktop Connection. I was able to switch between running programs during the price feed freeze, so the connection between my home computer and the VPS was fine.
We need a way to determine whether the latest quote is a valid and tradeable one. A quote that is 30 seconds old may still actually be valid - the broker may see no need to send a new tick because the market is in a quiet time e.g. around 00:00 UTC. But on the other hand, a quote that is 10 seconds old in the first hour of US session may be invalid. So simply checking that TimeCurrent() is from x seconds ago may not be a good solution.
So what are the best ways to check for and handle temporary price feed freezes?