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 AccountSummaryAsync, AccountInfoDoubleAsync, AccountInfoIntegerAsync
Quotes & symbol properties Symbol_Information SymbolInfoTickAsync, SymbolInfoDoubleAsync, SymbolsTotalAsync
Current positions & orders Position_Orders_Information PositionsTotalAsync, OpenedOrdersAsync, OpenedOrdersTicketsAsync
Historical trades Position_Orders_Information OrderHistoryAsync, PositionsHistoryAsync
Level II / Order book Market_Depth_DOM MarketBookAddAsync, MarketBookGetAsync, MarketBookReleaseAsync
Trading operations Trading_Operations OrderSendAsync, OrderModifyAsync, OrderCloseAsync
Pre-trade calculations Trading_Operations OrderCalcMarginAsync, OrderCheckAsync
Real-time updates Streaming_Methods OnSymbolTickAsync, OnTradeAsync, OnPositionProfitAsync

🔌 Usage pattern (gRPC protocol)

Every method is available in two versions: Async (recommended) and Sync (rare scenarios).

var summary = await account.AccountSummaryAsync();
var tick = await account.SymbolInfoTickAsync("EURUSD");

Sync Version (Legacy/specific scenarios only)

var summary = account.AccountSummary();
var tick = account.SymbolInfoTick("EURUSD");

📖 Read: Sync vs Async - When to Use What - Detailed guide with use cases and performance comparisons.


Every method follows the same shape:

  • Proto Service/Method: Service.Method(Request) → Reply
  • C# wrapper: await mt5Account.MethodAsync(...) or mt5Account.Method()
  • Reply structure: Reply.Data payload (proto-generated objects)
  • Return codes: 10009 = success; other codes = check error message

Timestamps = UTC (google.protobuf.Timestamp). For streaming subscriptions, use IAsyncEnumerable<T> with await foreach pattern.


📚 Full Index · All Method Specs


📄 Account Information

Complete Snapshot

Individual Properties


📊 Symbol Information

Current Quotes

Symbol Inventory & Management

Symbol Properties


📦 Positions & Orders

Current State

Historical Data


🛠 Trading Actions

Order Execution & Management

Pre-Trade Calculations


📈 Market Depth (DOM)

Level II Quotes


🔧 Additional Methods

Advanced Symbol Information

Trading 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 AccountSummaryAsync
Get account balance AccountInfoDoubleAsync (BALANCE)
Get account equity AccountInfoDoubleAsync (EQUITY)
Get account leverage AccountInfoIntegerAsync (LEVERAGE)
Get account currency AccountInfoStringAsync (CURRENCY)
SYMBOL INFORMATION
Get current price for symbol SymbolInfoTickAsync
List all available symbols SymbolsTotalAsync + SymbolNameAsync
Add symbol to Market Watch SymbolSelectAsync (true)
Get symbol digits (decimal places) SymbolInfoIntegerAsync (DIGITS)
Get point size for symbol SymbolInfoDoubleAsync (POINT)
Get symbol volume limits SymbolInfoDoubleAsync (VOLUME_MIN/MAX/STEP)
Get tick values for symbols TickValueWithSizeAsync
POSITIONS & ORDERS
Count open positions PositionsTotalAsync
Get all open positions (full details) OpenedOrdersAsync
Get position ticket numbers only OpenedOrdersTicketsAsync
Get historical orders OrderHistoryAsync
Get historical deals/trades PositionsHistoryAsync
MARKET DEPTH
Subscribe to Level II quotes MarketBookAddAsync
Get order book data MarketBookGetAsync
Unsubscribe from Level II MarketBookReleaseAsync
TRADING OPERATIONS
Open market BUY position OrderSendAsync (type=BUY)
Open market SELL position OrderSendAsync (type=SELL)
Place BUY LIMIT order OrderSendAsync (type=BUY_LIMIT)
Place SELL LIMIT order OrderSendAsync (type=SELL_LIMIT)
Place BUY STOP order OrderSendAsync (type=BUY_STOP)
Place SELL STOP order OrderSendAsync (type=SELL_STOP)
Modify SL/TP of position OrderModifyAsync
Close a position OrderCloseAsync
Calculate margin before trade OrderCalcMarginAsync
Validate trade before execution OrderCheckAsync
REAL-TIME SUBSCRIPTIONS
Stream live prices OnSymbolTickAsync
Monitor trade events OnTradeAsync
Track profit changes OnPositionProfitAsync
Monitor ticket changes OnPositionsAndPendingOrdersTicketsAsync
Detailed transaction log OnTradeTransactionAsync

🏗️ 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: package/Helpers/MT5Account.cs (NuGet package source)

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 → C# primitives) - No proto objects in return values - No auto-normalization

Location: MT5Service.cs

Documentation: MT5Service.Overview.md


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: MT5Sugar.cs

Documentation: MT5Sugar.API_Overview.md


🎓 Learning Path

Recommended sequence: Start from foundation (MT5Account) → Build up to convenience layers (MT5Service → MT5Sugar)

Step 1: Master the Foundation (MT5Account)

Why first: MT5Account is the foundation - everything else is built on top of it. Understanding the protocol level gives you complete control.

1. Read: This documentation folder (docs/MT5Account/)
2. Study: Proto definitions and gRPC communication
3. Understand: Request/Response patterns
4. Learn: Return codes and error handling
5. Practice: Low-level method calls

Goal: Deep understanding of MT5 protocol and terminal communication.

Documentation: MT5Account.Master.Overview.md (you are here!)


Step 2: Understand Wrappers (MT5Service)

Why second: Once you know the foundation, see how MT5Service simplifies it by wrapping proto objects.

1. Study: How MT5Service wraps MT5Account methods
2. Compare: Wrapper vs low-level implementations
3. Learn: Type conversions (proto → C# primitives)
4. Practice: Simplified method calls without proto objects

Goal: Learn to build clean API wrappers on top of complex protocols.

Documentation: MT5Service.Overview.md


Step 3: Use Convenience Layer (MT5Sugar)

Why last: With foundation + wrappers understood, appreciate how MT5Sugar adds auto-normalization and smart helpers.

1. Study: MT5Sugar convenience methods (~50 methods)
2. Learn: Auto-normalization, risk management, batch operations
3. Use: High-level methods for rapid strategy development
4. Build: Trading strategies using Sugar API

Goal: Rapid strategy development with production-ready convenience methods.

Documentation: MT5Sugar.API_Overview.md


Summary: MT5Account (foundation) → MT5Service (wrappers) → MT5Sugar (convenience)


💡 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
  • 10031 = No connection with trade server

Always check ReturnedCode field in trading operations.

Complete Reference: ReturnCodes_Reference_EN.md


C# Async Patterns

Request/Reply methods:

var result = await account.MethodAsync(parameters, deadline, cancellationToken);

Streaming methods:

await foreach (var data in account.OnMethodAsync(parameters, cancellationToken))
{
    // Process streaming data
}

Detailed Guide: Sync_vs_Async.md - When to use async vs sync, performance comparisons, best practices


⚠️ Important Notes

  • Demo account first: Always test on demo before live trading.
  • Check return codes: Every trading operation returns status code.
  • Validate parameters: Use OrderCheckAsync() before OrderSendAsync().
  • Handle errors: Network/protocol errors can occur.
  • Thread safety: Streams execute on background threads.
  • Resource cleanup: Unsubscribe from streams when done (use CancellationToken).
  • UTC timestamps: All times are in UTC, not local time.
  • Broker limitations: Not all brokers support all features (DOM, hedging, etc.).
  • Async/await: Always use await with async methods.
  • CancellationToken: Always provide cancellation tokens for long-running operations.

📋 Best Practices

Error Handling

try
{
    var result = await account.OrderSendAsync(request);
    if (result.ReturnedCode == 10009)
    {
        Console.WriteLine("✅ Success");
    }
    else
    {
        Console.WriteLine($"❌ Error: {result.Comment}");
    }
}
catch (RpcException ex)
{
    Console.WriteLine($"gRPC Error: {ex.Status}");
}

Streaming with Cancellation

var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
try
{
    await foreach (var tick in account.OnSymbolTickAsync(symbols, cts.Token))
    {
        // Process tick
    }
}
catch (OperationCanceledException)
{
    Console.WriteLine("Stream stopped");
}

"Trade safe, code clean, and may your async operations always complete successfully."