Official C# / .NET SDK for MetaTrader 4 Cloud API via gRPC & REST.
Connect, stream live ticks, and execute trades on any MT4 broker or prop firm from Linux containers, Windows, or macOS — without running a Windows VPS or desktop terminal.
- Zero Windows VPS: Stop paying $20–$80/month for buggy Windows servers. Run .NET MT4 bots in lightweight Linux Docker containers or Kubernetes.
- Ultra-Low Latency: High-speed gRPC streaming and execution co-located with London (LD4) and New York (NY4) broker data centers (<20ms execution).
- Universal MT4 Broker & Prop Firm Support: Connects to 500+ brokers and prop firms including FTMO, IC Markets, Pepperstone, Exness, FundedNext, Tickmill, XM, FXCM.
- Automatic Session Management: Session GUID (
id) is generated automatically by the server upon connection and attached to all subsequent requests. - Modern Async/Await: Strongly-typed async methods with automatic reconnects and stream multiplexing.
dotnet add package MetaRPC.MT4Clone the repository and run the examples out-of-the-box:
git clone https://github.com/MetaRPC/CSharpMT4.git
cd CSharpMT4
dotnet restore
# 1. Run with default TRIAL key:
dotnet run
# 2. Or pass your MetaRPC API key directly as an argument:
dotnet run your_api_key_here
# 3. Or use the MRPC_API_KEY environment variable:
export MRPC_API_KEY="your_api_key_here" # Windows CMD: set MRPC_API_KEY=your_api_key_here
dotnet run # Windows PowerShell: $env:MRPC_API_KEY="your_api_key_here"using System;
using System.Threading.Tasks;
using MetaRPC.CSharpMT4;
class Program
{
static async Task Main(string[] args)
{
// 1. Initialize account credentials
// Sign up at https://mrpc.pro/signup to get your free API key
var account = new MT4Account(
user: 12345678, // MT4 Login
password: "your_mt4_password", // MT4 Password
grpcServer: "https://mt4.mrpc.pro:443", // Cloud gRPC Endpoint
apiKey: "your_mrpc_api_key" // From https://mrpc.pro/my
);
// 2. Connect by broker server name
Console.WriteLine("Connecting to MetaTrader 4 Cloud...");
await account.ConnectByServerNameAsync("MetaQuotes-Demo", baseChartSymbol: "EURUSD", timeoutSeconds: 30);
Console.WriteLine("Connected successfully!");
// 3. Get real-time account summary
var summary = await account.AccountSummaryAsync();
Console.WriteLine($"Balance: ${summary.AccountBalance:N2}");
Console.WriteLine($"Equity: ${summary.AccountEquity:N2}");
Console.WriteLine($"Free Margin: ${summary.AccountMarginFree:N2}");
}
}- Sign Up: Create your free account at https://mrpc.pro/signup.
- Copy API Key: Open your portal dashboard at https://mrpc.pro/my and grab your personal API token.
- Connect: Pass your key in code or set the
MRPC_API_KEYenvironment variable:export MRPC_API_KEY="your_api_token_here"
| Environment | Host / URL | Port | Protocol | Purpose |
|---|---|---|---|---|
| MT4 Production gRPC | mt4.mrpc.pro |
443 |
TLS / gRPC | High-throughput trading & streaming |
| Interactive API UI (Swagger) | https://mt4.mrpc.pro/apiui | 443 |
HTTPS / REST | Interactive REST endpoints & testing |
| Portal Dashboard | https://mrpc.pro/my | 443 |
HTTPS | Manage terminals, copiers & keys |
| Account Registration | https://mrpc.pro/signup | 443 |
HTTPS | Instant free trial registration |
Tested and verified with over 500+ MetaTrader server environments:
- Prop Firms: FTMO, FundedNext, The Funded Trader, E8 Funding, Alpha Capital, SurgeTrader.
- Brokers: IC Markets, Pepperstone, Exness, Tickmill, XM, FXCM, FP Markets, Eightcap, AvaTrade.
- 📖 Comprehensive Documentation
- 🚀 Quick Start & First Project
- 📡 Live Market Data & gRPC Streaming
- 💼 Account Management & Order Execution
- 📊 Return Codes & Error Handling
This SDK is open-sourced under the MIT License.
Cloud infrastructure and API services are operated by MetaRPC.