Watch how to download trading robots for free
Find us on Telegram!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Views:
27546
Rating:
(24)
Published:
2009.10.30 16:29
Updated:
2014.04.21 14:54
SymbolsLib.mq4 (3.91 KB) view
\MQL4\Include\
SymbolsLib.mqh (1.56 KB) view
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

ATTENTION: Undocummented solution, it may not work in the other versions of MetaTrader

Among the standard MQL4 functions there is very useful function MarketInfo() which returns the various information on the financial instruments listed in"Market Watch" window. However, in some cases, the additional information about the instruments is need. For example, the list of the symbols listed in "Market Watch" window, their order in the list, the full description of the instrument, or full list of the financial instruments provided by broker.

It has been discovered, that during any changes in the "Market Watch" window, the client terminal opens and modifies the binary file symbols.sel in the history folder. Analysis of the structure of this file shows that the terminal records for the every instrument of the "Market Watch" window has a 128-byte structure. The first 12 bytes allocated for the symbol name, the other bytes are filled with the other information: Bid, Ask, High, Low, etc. The instument order is the same as in "Market Watch" window. And if the user changes the ordering of symbols, the changes are immediately reflected in the file.


Note: the first 4 bytes are reserved for MQL version and they are constant


However, the information contained in the file symbols.sel may not be complete. Especially if the "Market Watch" window has no all listed financial instruments. Therefore, if you need a complete list of available symbols, provided by broker, then this method will not work. The good idea based on analysis of file symbols.raw has been proposed by kaisa. However, its implementation using the API functions is not the best solution.

This problem can be solved and the "pure" MQL. Analysis of the structure of this file shows that each symbol is recorded in a file in the binary structure of the size of 1936 bytes. The first 12 bytes are for the short symbol name, and the next of 64-bytes block contain an extended symbol description.

On the basis of the analysis proposed here it has been developed library that contains a several functions for more information about financial instruments loaded in the client terminal.

Here is a list of the exported functions:

SymbolsList

- returns the symbol list (listed in "Market Watch" or all of the symbols).

SymbolDescription

- returns the detailed name description of the specified financial symbol.

SymbolType - returns a type of the financial instrument.

An example of the library usage is presented in the script SymbolsSample.mq4.


Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/9102

Market browse Market browse

This script will allow you to use the information about the market watch and the client terminal settings. It can be very useful to study the client terminal and market watch options.

Stairs strategy Stairs strategy

The multicurrency expert, which uses the "Stairs" strategy

The signal lines with alert after crossing The signal lines with alert after crossing

When the price is approaching to the Signal Lines, the indicator sends Alert.

Two Pole Smoothed Ehlers Oscillator Two Pole Smoothed Ehlers Oscillator

This oscillator is based on Ehlers' Two Pole Super Smoother, converted as an oscillator, and smoothed using Ehlers' Instantaneous trendline.