- 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)
Price representation accuracy and change steps
Earlier, we have already met two interrelated properties of the working symbol of the chart: the minimum price change step (Point) and the price presentation accuracy which is expressed in the number of decimal places (Digits). They are also available in Predefined variables. To get similar properties of an arbitrary symbol, you should query the SYMBOL_POINT and SYMBOL_DIGITS properties, respectively. The SYMBOL_POINT property is closely related to the minimum price change (known to an MQL program as the SYMBOL_TRADE_TICK_SIZE property) and its value (SYMBOL_TRADE_TICK_VALUE), usually in the currency of the trading account (but some symbols can be configured to use the base currency; you may contact your broker for details if necessary). The table below shows the entire group of these properties.
Identifier |
Description |
---|---|
SYMBOL_DIGITS |
The number of decimal places |
SYMBOL_POINT |
The value of one point in the quote currency |
SYMBOL_TRADE_TICK_VALUE |
SYMBOL_TRADE_TICK_VALUE_PROFIT value |
SYMBOL_TRADE_TICK_VALUE_PROFIT |
Current tick value for a profitable position |
SYMBOL_TRADE_TICK_VALUE_LOSS |
Current tick value for a losing position |
SYMBOL_TRADE_TICK_SIZE |
Minimum price change in the quote currency |
All properties except SYMBOL_DIGITS are real numbers and are requested using the SymbolInfoDouble function. The SYMBOL_DIGITS property is available via SymbolInfoInteger. To test the work with these properties, we will use ready-made classes SymbolFilter and SymbolMonitor, which will automatically call the desired function for any property.
We will also improve the SymbolFilter class by adding a new overload of the select method, which will be able to fill not only an array with the names of suitable symbols but also another array with the values of their specific property.
In a more general case, we may be interested in several properties for each symbol at once, so it is advisable to use not one of the built-in data types for the output array but a special composite type with different fields.
In programming, such types are called tuples and are somewhat equivalent to MQL5 structures.
template<typename T1,typename T2,typename T3> // we can describe up to 64 fields
|
However, structures require a preliminary description with all fields, while we do not know in advance the number and list of requested symbol properties. Therefore, in order to simplify the code, we will represent our tuple as a vector in the second dimension of a dynamic array that receives the results of the query.
T array[][S]; |
As a data type T we can use any of the built-in types and enumerations used for properties. Size S must match the number of properties requested.
To tell the truth, such a simplification limits us in one query to values of the same types, that is, only integers, only reals, or only strings. However, filter conditions can include any properties. We will implement the approach with tuples a little later, using the example of filters of other trading entities: orders, deals, and positions.
So the new version of the SymbolFilter::select method takes as an input a reference to the property array with property identifiers to read from the filtered symbols. The names of the symbols themselves and the values of these properties will be written to the symbols and data output arrays.
template<typename E,typename V>
|
Additionally, the new method can sort the output array by the first dimension (the first requested property): this functionality is left for independent study using source codes. To enable sorting, set the sort parameter to true. Arrays with symbol names and data are sorted consistently.
To avoid tuples in the calling code when only one property needs to be requested from the filtered characters, the following select option is implemented in SymbolFilter: inside it, we define intermediate arrays of properties (properties) and values (tuples) with size 1 in the second dimension, which are used to call the above full version of select.
template<typename E,typename V>
|
Using the advanced filter, let's try to build a list of symbols sorted by tick value SYMBOL_TRADE_TICK_VALUE (see file SymbolFilterTickValue.mq5). Assuming that the deposit currency is USD, we should obtain a value equal to 1.0 for Forex instruments quoted in USD (of the type XXXUSD). For other assets, we will see non-trivial values.
#include <MQL5Book/SymbolFilter.mqh>
|
Here is the result of running the script.
===== Tick values of the symbols (13) =====
|