Skip to content

MT5Account - Master Overview

One page to orient fast: what lives where, how to choose the right API, and jump links to every overview and method spec in this docs set.


🚦 Start here - Section Overviews


🧭 How to pick an API

If you need… Go to… Typical calls
Account snapshot Account_Information accountSummary, accountInfoDouble, accountInfoInteger, accountInfoString
Quotes & symbol properties Symbol_Information symbolInfoTick, symbolInfoDouble, symbolInfoInteger, tickValueWithSize
Current positions & orders Positions_And_Orders positionsTotal, openedOrders, openedOrdersTickets
Historical trades Positions_And_Orders orderHistory, positionsHistory
Level II / Order book Market_Depth_DOM marketBookAdd, marketBookGet, marketBookRelease
Trading operations Trading orderSend, orderModify, orderClose
Pre-trade calculations Trading orderCalcMargin, orderCalcProfit, orderCheck
Real-time updates Subscriptions onSymbolTick, onTrade, onPositionProfit, onTradeTransaction

🔌 Usage pattern (gRPC protocol)

Every method follows the same shape:

  • Proto Service/Method: Service.Method(Request) → Reply
  • Java wrapper: MT5Account.method(...)
  • Reply structure: Reply.getData() payload (proto-generated objects)
  • Return codes: 10009 = success; other codes = check error message

Timestamps = UTC (google.protobuf.Timestamp). For streaming subscriptions, use StreamObserver<T> pattern.


📚 Full Index · All Method Specs


📄 Account Information

Complete Snapshot

Individual Properties


📊 Symbol Information

Current Quotes

Symbol Inventory & Management

Symbol Properties

Trading Calculations


📦 Positions & Orders

Current State

Historical Data


📈 Market Depth (DOM)

Level II Quotes


🛠 Trading Actions

Order Execution & Management

Pre-Trade Calculations


📡 Subscriptions (Streaming)

Real-Time Price Updates

Trading Events

Position Monitoring


🎯 Quick Navigation by Use Case

I want to... Use this method
ACCOUNT INFORMATION
Get complete account snapshot accountSummary
Get account balance accountInfoDouble (BALANCE)
Get account equity accountInfoDouble (EQUITY)
Get account leverage accountInfoInteger (LEVERAGE)
Get account currency accountInfoString (CURRENCY)
SYMBOL INFORMATION
Get current price for symbol symbolInfoTick
List all available symbols symbolsTotal + symbolName
Add symbol to Market Watch symbolSelect (true)
Get symbol digits (decimal places) symbolInfoInteger (DIGITS)
Get point size for symbol symbolInfoDouble (POINT)
Get symbol volume limits symbolInfoDouble (VOLUME_MIN/MAX/STEP)
Get tick values for symbols tickValueWithSize
POSITIONS & ORDERS
Count open positions positionsTotal
Get all open positions (full details) openedOrders
Get position ticket numbers only openedOrdersTickets
Get historical orders orderHistory
Get historical deals/trades positionsHistory
MARKET DEPTH
Subscribe to Level II quotes marketBookAdd
Get order book data marketBookGet
Unsubscribe from Level II marketBookRelease
TRADING OPERATIONS
Open market BUY position orderSend (type=BUY)
Open market SELL position orderSend (type=SELL)
Place BUY LIMIT order orderSend (type=BUY_LIMIT)
Place SELL LIMIT order orderSend (type=SELL_LIMIT)
Place BUY STOP order orderSend (type=BUY_STOP)
Place SELL STOP order orderSend (type=SELL_STOP)
Modify SL/TP of position orderModify
Close a position orderClose
Delete pending order orderClose
Calculate margin before trade orderCalcMargin
Calculate profit for trade orderCalcProfit
Validate trade before execution orderCheck
REAL-TIME SUBSCRIPTIONS
Stream live prices onSymbolTick
Monitor trade events onTrade
Track profit changes onPositionProfit
Monitor ticket changes onPositionsAndPendingOrdersTickets
Detailed transaction log onTradeTransaction

🏗️ API Architecture

Layer 1: MT5Account (Low-Level)

What: Direct proto/gRPC communication with MT5 terminal.

When to use: - Need full control over protocol - Building custom wrappers - Proto-level integration required

Characteristics: - Works with proto Request/Response objects - Raw gRPC method calls - Complete access to all MT5 functions - Highest complexity

Location: src/main/java/io/metarpc/mt5/MT5Account.java

Documentation: This folder (you are here!)


Layer 2: MT5Service

What: Simplified wrapper methods without proto complexity.

When to use: - Want simplified API but not auto-normalization - Building custom convenience layers - Need direct data returns

Characteristics: - Simple method signatures - Type conversions (proto → Java primitives) - No proto objects in return values - No auto-normalization

Location: src/main/java/io/metarpc/mt5/MT5Service.java


Layer 3: MT5Sugar

What: High-level convenience API with ~50 smart methods.

When to use: - Most trading scenarios (95% of cases) - Want auto-normalization - Need risk management helpers - Building strategies quickly

Characteristics: - Auto-normalization of volumes/prices - Risk-based position sizing - Batch operations - Smart helpers

Location: src/main/java/io/metarpc/mt5/MT5Sugar.java

Documentation: MT5Sugar.Overview.md


🎓 Learning Path

Beginner: Start High (MT5Sugar)

1. Read: MT5Sugar.Overview.md
2. Use: High-level convenience methods
3. Run: examples/sugar/
4. Drop down when needed

Recommendation: Start with MT5Sugar for easiest learning curve.


Intermediate: Understand Wrappers (MT5Service)

1. Study: How MT5Service wraps MT5Account
2. Compare: Wrapper vs low-level implementations
3. Run: examples/services/
4. Use: When auto-normalization not desired

Advanced: Master Protocol (MT5Account)

1. Read: This documentation folder (MT5Account/)
2. Study: Proto definitions (src/main/proto/)
3. Run: examples/lowlevel/
4. Understand: Complete proto/gRPC communication

Goal: Deep understanding of MT5 protocol and terminal communication.



💡 Key Concepts

Proto Return Codes

  • 10009 = Success / DONE
  • 10004 = Requote
  • 10006 = Request rejected
  • 10013 = Invalid request
  • 10014 = Invalid volume
  • 10015 = Invalid price
  • 10016 = Invalid stops
  • 10018 = Market closed
  • 10019 = Not enough money

Always check returnedCode field in trading operations.


⚠️ Important Notes

  • Demo account first: Always test on demo before live trading.
  • Check return codes: Every trading operation returns status code.
  • Validate parameters: Use orderCheck() before orderSend().
  • Handle errors: Network/protocol errors can occur.
  • Thread safety: Streams execute on background threads.
  • Resource cleanup: Unsubscribe from streams when done.
  • UTC timestamps: All times are in UTC, not local time.
  • Broker limitations: Not all brokers support all features (DOM, hedging, etc.).

"Trade safe, code clean, and may your proto buffers never overflow."