Login / Register
Add a review
Log in
Sign UP
[bws_google_captcha]
OrderBook History Library

0.00

Order Book, also known as Market Book, market depth, price glass, Level 2, is a dynamically updated table provided by a broker with data on the current volumes of trading orders for purchase and sale for various price levels near the Bid and Ask of a particular financial instrument.

MetaTrader 5 provides the ability to broadcast a glass of prices, but only in real time. This library OrderBook History Library allows you to read the state of the glass in the past from the archives created by the expert OrderBook Recorder. The library can be used in indicators and experts, including the tester.

This library, in particular, is used to read the glass by the OrderBook Cumulative Indicator and the OrderBook History Playback demo expert.

Below is an example of a header file for connecting the library:

The input parameters are defined for convenience – so that their values can be passed to the OrderBook_Init function.

  • OrderBook_FileFolder is the name of the root folder where the subfolders with the cup files are located; by default, “Books” is used in OrderBook Recorder; each subfolder is named by the symbol name; for example, for the GAZP ticker, we get the files MQL5/Files/Books/GAZP/*.hob;
  • OrderBook_UseCommonFiles – option to read files from the folder of the current terminal (false, by default) or from the shared folder of all terminals (true);
  • OrderBook_TimeZoneCorrection – date and time correction for cases when the archives of the glass are read in the terminal, where the server time zone is different from the one used when recording archives; set in seconds; for example, if the glass was saved with the server time GMT 3 and then reproduced on the server quotes with GMT 2, the correction should be equal to 1 hour (-3600 seconds), since at GMT 2 times are 1 hour behind (i.e. less) GMT 3;

[spoiler title=”Read More…”]

Functions

  • OrderBook_Init – library initialization function, should be called from OnInit; as the first parameter, a pointer to the OnBookEvent event handler should be passed;
  • OrderBook_MarketBookAdd, OrderBook_MarketBookRelease, OrderBook_MarketBookGet are functions completely similar to the corresponding MQL functions; when working online, standard functions are called directly – this allows you to embed the library, practically without changing the code; when working in the tester, the library accesses the archive; subscription is allowed only for the current graph symbol;
  • OrderBook_MarketBookPeek is an analogue of OrderBook_MarketBookGet, which always accesses the archive – both in the tester and online; there is no call to MarketBookGet;
  • OrderBook_OnTick – an optional option to run the library in the tester from onTick;
  • OrderBook_OnTimer – an optional option to run the library in the tester from OnTimer;
  • OrderBook_CheckForEvents is an optional option to run the library in the tester and online on demand, for a given date and time;

Declaring #define ORDERBOOK_SUBSTITUTE before including the header file implicitly replaces all calls to standard functions in your code with library ones.

[/spoiler]

Add review
Reviews ( 0 ):