Getting Started with GoMT4ΒΆ
Quick Setup & Overview - Start automating your trading with GoMT4 (Go for MetaTrader 4) in minutes.
π― What is GoMT4?ΒΆ
GoMT4 is an industrial-grade, type-safe Go client library for interacting with MetaTrader 4 terminals via high-performance gRPC. It eliminates complex C++ DLL wrappers and provides direct, reliable programmatic trading.
π Key AdvantagesΒΆ
- π High Throughput: Native gRPC streaming for sub-millisecond price ticks and trade execution.
- π‘οΈ Three-Layer Architecture: Low-level gRPC (
MT4Account), typed wrapper methods (MT4Service), and high-level convenience (MT4Sugar). - π Resilient Connection: Auto-reconnect, exponential backoff, and transparent channel healing.
- πΌ Production Ready: Fully verified across institutional accounts, hedge fund systems, and automated retail bots.
π¦ InstallationΒΆ
Install GoMT4 via your standard Go package manager:
π API Key & AuthenticationΒΆ
Connecting to MetaRPC production endpoints (mt4.mrpc.pro:443) requires an API key:
- Sign Up: Create an account for free at https://mrpc.pro/signup.
- Generate API Key: In your MetaRPC Portal dashboard at https://mrpc.pro/my, go to API Keys to generate and copy your personal API token.
- Configure Connection: Pass your API key / token along with the server address (
mt4.mrpc.pro:443) in your connection settings.
π Automatic Account ID & AuthenticationΒΆ
MetaRPC endpoints require authentication and session management:
1. APIKey: Your personal authentication token from https://mrpc.pro/my (obtained by registering at https://mrpc.pro/signup). Sent in the APIKey header.
2. id: A terminal session GUID returned by Connect / ConnectEx (terminalInstanceGuid).
π‘ Seamless Automation: You do not need to call
GetIdor provide anidheader when connecting. The server automatically generates a session GUID upon connection and returns it to the caller. The SDK automatically captures this session ID and attaches it alongside yourAPIKeyto all subsequent requests and streaming subscriptions.
π Minimal Connection ExampleΒΆ
Here is how easy it is to initialize MT4Account, connect to your MetaTrader terminal, and retrieve your account balance:
client, err := mt.NewMT4Account(user, password, grpcServer)
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
err = client.ConnectByServerName(ctx, serverName, "EURUSD")
summary, err := client.AccountSummary(ctx)
fmt.Printf("Balance: %.2f, Equity: %.2f\n", summary.Balance, summary.Equity)
πΊοΈ Documentation Road MapΒΆ
To get the most out of GoMT4, follow this suggested reading order:
- π Your First Project - Build and run a working project in 10 minutes.
- πΊοΈ Project Map - Understand the 3 architectural layers and interaction flow.
- π Glossary - Essential MetaTrader 4 and algorithmic trading terminology.
- π£ MT4 for Beginners - Step-by-step terminal setup and demo account guide.
- π‘ gRPC Streaming - Subscribe to ticks, trades, DOM, and position updates.
- π Return Codes - Complete reference of broker and gateway return codes.