Your First Project in 10 Minutes (C#)¶
Hands-on Quick Start - Create a working trading project with MetaTrader 5 and CSharpMT5 from scratch.
Step 0: Obtain Your API Key¶
To connect to MetaRPC endpoints (mt5.mrpc.pro:443), obtain your API key:
-
Register for free at https://mrpc.pro/signup.
-
Generate your API token in your dashboard at https://mrpc.pro/my.
-
Set your token in your environment or connection config.
Step 1: Create Your Project¶
Create a new directory for your trading bot:
Install the package:
Step 2: Write Your Trading Code¶
Create your main application file and paste the following snippet:
using mt5_term_api;
using MetaRPC.MT5;
// Session ID generation on Connect and authentication are handled automatically
var account = new MT5Account(user, password, grpcServer, apiKey);
await account.ConnectByServerNameAsync(serverName, "EURUSD", 30);
var summary = await account.AccountSummaryAsync();
Console.WriteLine($"Balance: {summary.AccountBalance}, Equity: {summary.AccountEquity}");
Step 3: Run the Program¶
Run your application:
🚀 Next Steps¶
Congratulations! You have successfully established a direct gRPC connection to MetaTrader 5. Next:
- Explore gRPC Streaming to listen to live ticks.
- Check the API Reference for all 40+ available terminal methods.
- Learn about high-level risk management and auto-normalization in MT5Sugar.