Skip to content

MT5Account · Market Depth (DOM) - Overview

Level II quotes, order book data, market depth subscription. Use this page to choose the right API for accessing deep market liquidity information.

📁 What lives here


🧭 Plain English

  • MarketBookAddenable Level II quotes for a symbol (must do first).
  • MarketBookGetpull current order book (bid/ask sides with volumes).
  • MarketBookReleasedisable Level II when done (free resources).

Rule of thumb: AddGetRelease. Always subscribe before retrieving data, and unsubscribe when finished.


Quick choose

If you need… Use Returns Key inputs
Enable Market Depth for symbol MarketBookAdd Success/failure symbol
Get current order book (bid/ask sides) MarketBookGet Order book entries symbol (must be subscribed)
Disable Market Depth for symbol MarketBookRelease Success/failure symbol

❌ Cross‑refs & gotchas

  • Must subscribe first: Call MarketBookAdd before MarketBookGet.
  • Not all symbols: Market Depth may not be available for all symbols.
  • Not all brokers: Some brokers don't provide Level II data.
  • Resource intensive: Unsubscribe when done to free resources.
  • Pull mode: Use MarketBookGet to poll; no streaming available.
  • Bid side: Buy orders (demand) at various price levels.
  • Ask side: Sell orders (supply) at various price levels.
  • Volume at level: Shows liquidity available at each price.
  • Order book types: SELL orders (ask side), BUY orders (bid side).

🟢 Minimal snippets

// Subscribe to Market Depth
account.marketBookAdd("EURUSD");
// Get order book data
var reply = account.marketBookGet("EURUSD");
var data = reply.getData();

System.out.printf("Market Depth for EURUSD (%d levels):%n", data.getMqlBookInfosCount());
for (int i = 0; i < data.getMqlBookInfosCount(); i++) {
    var entry = data.getMqlBookInfos(i);
    String type = entry.getType().getNumber() == 1 ? "SELL" : "BUY ";
    System.out.printf("  %s %.5f: %.2f lots%n",
        type, entry.getPrice(), entry.getVolumeReal());
}
// Calculate total liquidity by side
var reply = account.marketBookGet("GBPUSD");
var data = reply.getData();

double totalBidVolume = 0;
double totalAskVolume = 0;

for (int i = 0; i < data.getMqlBookInfosCount(); i++) {
    var entry = data.getMqlBookInfos(i);
    // Type: 0 = SELL (ask side), 1 = BUY (bid side)
    if (entry.getType().getNumber() == 1) {
        totalBidVolume += entry.getVolumeReal();
    } else {
        totalAskVolume += entry.getVolumeReal();
    }
}

System.out.printf("Total bid liquidity: %.2f lots%n", totalBidVolume);
System.out.printf("Total ask liquidity: %.2f lots%n", totalAskVolume);
System.out.printf("Bid/Ask ratio: %.2f%n", totalBidVolume / totalAskVolume);
// Unsubscribe when done
account.marketBookRelease("EURUSD");
// Complete workflow: Subscribe → Get → Release
try {
    // 1. Subscribe
    account.marketBookAdd("XAUUSD");

    // 2. Get data
    var reply = account.marketBookGet("XAUUSD");
    var data = reply.getData();

    // 3. Process order book
    System.out.printf("Best bid: %.2f (%.2f lots)%n",
        data.getBookListBid(0).getPrice(),
        data.getBookListBid(0).getVolume());
    System.out.printf("Best ask: %.2f (%.2f lots)%n",
        data.getBookListAsk(0).getPrice(),
        data.getBookListAsk(0).getVolume());

} finally {
    // 4. Always unsubscribe
    account.marketBookRelease("XAUUSD");
}

See also

  • Symbol info: SymbolInfoTick - Level I quotes (bid/ask only)
  • Subscriptions: OnSymbolTick - real-time price stream
  • Trading: OrderSend - place orders based on liquidity analysis