OrderBook Recorder
- Utilities
- Stanislav Korotky
- Version: 1.2
- Updated: 9 May 2020
Order Book, known also as Market Book, market depth, Level 2, - is a dynamically updated table with current volumes of orders to buy and to sell specific financial instument at price levels near Bid and Ask.
MetaTrader 5 provides the means for receiving market book from your broker in real time. The expert OrderBook Recorder records market book changes and stores them in local files for further usage in indicators and expert adviser, including testing in the tester.
The expert stores market book of the work symbol of the chart, where it's attached.
The files are created in the folder MQL5/Files/Books, where "Books" - is an adjustable name, given through a special input parameter (see below). Inside the folder another folder is created for every specific work symbol, which contains every day records in dedicated file YYYYMMDD.hob, where YYYY, MM, DD - year, month, day correspondingly. The extension "hob" stands for History of Order Book. For example, the ticker GAZP will produce the files MQL5/Files/Books/GAZP/*.hob.
The data from the files should be read by the library OrderBook History Library. In particular, this library is used for reading market books in the indicator OrderBook Cumulative Indicator and demo expert adviser OrderBook History Playback. The library is intended to embedding into your MQL programs (source codes of the programs are required).
The expert adviser shows a comment like that:
YYYY.MM.DD HH:SS N [X]
YYYY.MM.DD HH:SS - date and time of the latest processed event;
N - total number of events written by the expert into current file since its start;
X - the size of the market book in the latest event;
Parameters
- FileFolder - a string with the root folder name, where to place all files with market books for all symbols (in a separate subfolder for every symbol), by default - "Books";
Attention! Current server time is stored in the files "as is", preserving offset to GMT. Reading file archives for the same account or other accounts on the same server requires no further processing. However, if the archive is transferred to a terminal, connected to a server with different time zone (offset to GMT), one should properly adjust the parameter OrderBook_TimeZoneCorrection in the library OrderBook History Library. Please note, that the tester does always emulate a server with the timezone GMT+0, regardless of actual timezone of the quotes!
User didn't leave any comment to the rating