Passes the status of the Depth of Market for a custom symbol. The function allows broadcasting the Depth of Market as if the prices arrive from a broker's server.
[in] Custom symbol name.
[in] The array of MqlBookInfo type data fully describing the Depth of Market status — all buy and sell requests. The passed Depth of Market status completely replaces the previous one.
[in] The number of 'books' array elements to be passed to the function. The entire array is used by default.
Number of added ticks or -1 in case of an error.
The CustomBookAdd function works only for custom symbols the Depth of Market is opened for — via the platform interface or the MarketBookAdd function.
When throwing the Depth of Market in, the symbol's Bid and Ask prices are not updated. You should control the change of the best prices and throw in the ticks using CustomTicksAdd.
The passed data are checked for validity: prices and volumes should not be negative, as well as type, price and volume (MqlBookInfo.volume or MqlBookInfo.volume_real) should be specified for each element. If at least one Depth of Market element is described incorrectly, the system discards the passed status entirely.
The MqlBookInfo.volume_real extended accuracy volume has a higher priority over the regular MqlBookInfo.volume. If both values are specified for the Depth of Market element, the volume_real one is used.
The order of the MqlBookInfo elements in the 'books' array does not matter. When saving the data, the terminal sorts them by price on its own.
When saving data, the "Book depth" (SYMBOL_TICKS_BOOKDEPTH) parameter of the recipient custom symbol is checked. If the number of sell requests exceeds this value in the passed Depth of Market, the excess levels are discarded. The same is true for buy requests.
Sample filling of the 'books' array:
Depth of Market status