Download MetaTrader 5

Discussion of article "MQL5 Cookbook: Implementing Your Own Depth of Market"

To add comments, please log in or register
MetaQuotes Software Corp.
MetaQuotes Software Corp.  

New article MQL5 Cookbook: Implementing Your Own Depth of Market has been published:

This article demonstrates how to utilize Depth of Market (DOM) programmatically and describes the operation principle of CMarketBook class, that can expand the Standard Library of MQL5 classes and offer convenient methods of using DOM.

MQL5 language is constantly evolving and offering more opportunities for operation with exchange information every year. One of such exchange data types is information about Depth of Market. It is a special table showing price levels and volumes of limit orders. MetaTrader 5 has a built-in Depth of Market for displaying limit orders, but it is not always sufficient. First of all, your Expert Advisor has to be given a simple and convenient access to Depth of Market. Certainly, MQL5 language has few special features for working with such information, but they are low-level features that require additional mathematical calculations.

However, all intermediate calculations can be avoided. All you have to do is to write a special class for working with Depth of Market. All complex calculations will be carried out within Depth of Market, and the class itself will provide convenient ways for operation with DOM prices and levels. This class will enable an easy creation of the efficient panel in a form of an indicator, which will be promptly reflecting the current state of prices in Depth of Market:

Fig. 1. Depth of Market displayed as a panel

After reading the first chapter of this article, it will become clear that the regular Depth of Market offered by MetaTrader 5 has impressive capabilities. We will not try to duplicate all these multiple opportunities in our indicator, as our task will be completely different. With a practical example of creating user-friendly Depth of Market trading panel we will show that the principles of object-oriented programming allow relatively easy handling of complex data structures. We will ensure that it won't be difficult to gain access to Depth of Market directly from your Expert Advisor with MQL5 and, consequently, to visualize its representation as it is convenient for us.

Author: Vasiliy Sokolov

Pedro Miranda
Pedro Miranda  


Thanks so much for the contribution.

It is exactly what I was searching for.

Depth of Market can be a great indication for scalpers.

But the problem is I never really see depth of market volume information in my terminals.

How to get access to the volume information provided by the broker? 

Vasiliy Sokolov
Vasiliy Sokolov  
Hi! Market Book is usually only available on the exchange markets. Connect to any exchange and use it!
Eduardo Gonzatti
Eduardo Gonzatti  

hi there, thanks for the article, very straightforward.

Im trying to call some "N" dephts of market on the EA and im trying to modify the MarketBoook.mqh code in order create new doubles and integers that could "invoke" those 2nd, 3rd, "N" dephts directly , without looping and wasting time.

edit:i managed to do it, coding some new integers and doubles inside the MarketBoook file, and now im calling then from other mq5's.

the question that remains is: is there some other way that would be more efficient, or is that, as you show in the article, the most optimized way of doing so?

thanks a lot

To add comments, please log in or register