- Getting available symbols and Market Watch lists
- Editing the Market Watch list
- Checking if a symbol exists
- Checking the symbol data relevance
- Getting the last tick of a symbol
- Schedules of trading and quoting sessions
- Symbol margin rates
- Overview of functions for getting symbol properties
- Checking symbol status
- Price type for building symbol charts
- Base, quote, and margin currencies of the instrument
- Price representation accuracy and change steps
- Permitted volumes of trading operations
- Trading permission
- Symbol trading conditions and order execution modes
- Margin requirements
- Pending order expiration rules
- Spreads and order distance from the current price
- Getting swap sizes
- Current market information (tick)
- Descriptive symbol properties
- Depth of Market
- Custom symbol properties
- Specific properties (stock exchange, derivatives, bonds)
Checking the symbol data relevance
Due to the distributed client-server architecture, client and server data may occasionally be different. For example, this can happen immediately after the start of the terminal session, when the connection is lost, or when the computer resources are heavily loaded. Also, the symbol will most likely remain out of sync for some time immediately after it is added to the Market Watch. The MQL5 API allows you to check the relevance of quote data for a particular symbol using the SymbolIsSynchronized function.
bool SymbolIsSynchronized(const string name)
The function returns true if the local data on the symbol named name is synchronized with the data on the trade server.
The section Obtaining characteristics of price arrays, among other timeseries properties, introduced the SERIES_SYNCHRONIZED property which returns an attribute of synchronization that is narrower in its meaning: it applies to a specific combination of a symbol and a timeframe. In contrast to this property, the SymbolIsSynchronized function returns an attribute of synchronization of the general history for a symbol.
The construction of all timeframes starts only after the completion of the history download. Due to the multi-threaded architecture and parallel computing in the terminal, it might happen that SymbolIsSynchronized will return true, and for a timeframe on the same symbol, the SERIES_SYNCHRONIZED property will be temporarily equal to false.
Let's see how the new function works in the SymbolListSync.mq5 indicator. It is designed to periodically check all symbols from Market Watch for synchronization. The check period is set by the user in seconds in the SyncCheckupPeriod parameter. It causes the timer to start in OnInit.
#property indicator_chart_window
|
In the OnTimer handler, in a loop, we call SymbolIsSynchronized and collect all unsynchronized symbols into a common string, after which they are displayed in the comment and the log.
void OnTimer()
|
For example, if we add some previously missing symbol (Brent) to the Market Watch, we get an entry like this:
Unsynced symbols:
|
Under normal conditions, most of the time (while the indicator is running) there should be no such messages in the log. However, a flood of alerts may be generated during communication problems.