• Información general
  • Comentarios (1)
  • Discusión
  • Novedades

OrderBook History Playback

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, but in real time only, without access to its history. This expert adviser OrderBook History Playback allows you to playback the market book events on the history using files, created by OrderBook Recorder. The expert is based on the library OrderBook History Library, which can be as well embedded into your expert adviser or indicator (source codes are required). The library sends appropriate OnBookEvent events to your program in the tester, which make it possible to test trading strategies based on volumes analysis in the market book.

The archive files can be stored in the data folder of the terminal (usually, it looks like C:\Program Files\MetaTrader 5 MetaQuotes\MQL5\Files), or in the common data folder for all terminals (for example, 'C:\Users\<UserName>\AppData\Roaming\MetaQuotes\Terminal\Common\Files'). In either case, inside the folder another subfolder is used as a root for all market books, and the name of the subfolder is specified in the input parameter OrderBook_FileFolder, by default - "Books". Inside the root subfolder another level of subfolders is created - each subfolder corresponds to a specific work symbol, and every single day data is saved in a file YYYYMMDD.hob, where YYYY, MM, DD are 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.

This is a non-trading expert, it does only show a comment with available information of the market book live or on the history. On every single record the following information is displayed: index, requested trade types (S for sells, B for buys), price level, volume.


  • ShowCursor - an option to enable one of the 2 modes: false (by default) - monitors the market book online; true - creates a vertical line as a cursor, which can be dragged to highlight a bar in the past; if the market book data is available for this bar, it's displayed in the comment; only one book is shown per bar, but normally many events are available for a single bar in the file (up to one event per tick), so custom source code can analyze much more data;
  • TimerPeriod - period of the timer, in seconds, by default - 0, which means no timer, and the library is executed by ticks; the timer is useful on weekends, and on slow market;
  • OrderBook_FileFolder - a name of the root folder, where subfolders and files of the market books are stored; by default - "Books"; every subfolder is named according to specific work symbol;
  • OrderBook_UseCommonFiles - an option for reading files from the data folder of the current terminal (false, by default) or from the common data folder for all terminals (true); use the common folder for testing this and other expert advisers in the local tester; otherwise, all the hob-files should be linked to the source code using the directive #property tester_file;
  • OrderBook_TimeZoneCorrection - a correction of date and time, which is required in case, that archives are read in a terminal with a timezone, which differs from a timezone of the terminal where the archives were created; specified in seconds; for example, if the market book was saved with the server time in GMT+3, and then it's applied on quotes from a server, where time is in GMT+2, the correction should be 1 hour (-3600 seconds), because times in GMT+2 go 1 hour late in comparison to (i.e. they are 1 hour smaller than) GMT+3; 15:00 in GMT+3 is 14:00 in GMT+2;
Nikolay Gaylis
Nikolay Gaylis 2019.01.14 08:28 

El usuario no ha dejado ningún comentario para su valoración

Versión 1.1 2019.04.20
Starting from build 1930 MetaQuotes broke MQL5 back compatibility with MqlBookInfo structure by adding new field volume_real into it.

This version of the product supports new structure format, but it will not work on older builds.