|
CustomBookAdd
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.
bool CustomBookAdd(
|
Parameters
symbol
[in] Custom symbol name.
books[]
[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.
count=WHOLE_ARRAY
[in] The number of 'books' array elements to be passed to the function. The entire array is used by default.
Return Value
true – success, otherwise – false. To get information about the error, call the GetLastError() function.
Note
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 function verifies the accuracy of transmitted data: the type, price and volume must be indicated for each element. Furthermore, MqlBookInfo.volume and MqlBookInfo.volume_real must not be zero or negative; if both volumes are negative, this will be considered an error. You can specify any of the volumes or both of them: the one that is indicated or is positive will be used:
volume=-1 && volume_real=2 — volume_real=2 will be used,
|
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 |
Filling books[] |
---|---|
books[0].type=BOOK_TYPE_SELL; |
Example:
//+------------------------------------------------------------------+ |
See also