- 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)
Editing the Market Watch list
Using the SymbolSelect function, the MQL program developer can add a specific symbol to Market Watch or remove it from there.
bool SymbolSelect(const string name, bool select)
The name parameter contains the name of the symbol being affected by this operation. Depending on the value of the select parameter, a symbol is added to Market Watch (true) or removed from it. Symbol names are case-sensitive: for example, "EURUSD.m" is not equal to "EURUSD.M".
The function returns an indication of success (true) or error (false). The error code can be found in _LastError.
A symbol cannot be removed if there are open charts or open positions for this symbol. In addition, you cannot delete a symbol that is explicitly used in the formula for calculating a synthetic (custom) instrument added to Market Watch.
It should be kept in mind that even if there are no open charts and positions for a symbol, it can be indirectly used by MQL programs: for example, they can read its history of quotes or ticks. Removing such a symbol may cause problems in these programs.
The following script SymbolRemoveUnused.mq5 is able to hide all symbols that are not used explicitly, so it is recommended to check it on a demo account or save the current symbols set through the context menu first.
#include <MQL5Book/MqlError.mqh>
|
After the user confirms the analysis of the list of symbols, the program attempts to hide each symbol sequentially by calling SymbolSelect(s, false). This only works for instruments that are not used explicitly. The enumeration of symbols is performed in the reverse order so as not to violate the indexing. All successfully removed symbols are collected in the removed array. The log displays statistics and the array itself.
If Market Watch is changed, the user is then given the opportunity to restore all deleted symbols by calling SymbolSelect(removed[i], true) in a loop.
if(r > 0)
|
Here's what the log output might look like.
Can't remove 'EURUSD': MARKET_SELECT_ERROR (4305)
|
Please note that although the symbols are restored in their original order, as they were in Market Watch relative to each other, the addition occurs at the end of the list, after the remaining symbols. Thus, all "busy" symbols will be at the beginning of the list, and all the restored will follow them. Such is the specific operation of SymbolSelect: a symbol is always added to the end of the list, that is, it is impossible to insert a symbol in a specific position. So, the rearrangement of the list elements is available only for manual editing.