MT4 Client gRPC example for C#

easy direct connection to any MT4 and MT5 server

MT4 Client gRPC example for C#

Ready to run project:

https://git.mtapi.io/root/grpc-proto/-/archive/main/grpc-proto-main.zip?path=mt4/charpExample

  1. Firstly need to download libraries at you project folder:

    git clone https://git.gendocu.com/mtapiio/mt4grpc.git --branch master  mt4grpc 

    Or download like zip:
    https://git.gendocu.com/mtapiio/mt4grpc/archive/master.zip

  2. Add to your project reference to mt4grpc project.

  3. After that you can run this simple example.

Channel channel = new Channel("mt4grpc.mtapi.io:443", ChannelCredentials.SecureSsl);
var connection = new Connection.ConnectionClient(channel);
var service = new  Service.ServiceClient(channel);
var tarding = new Trading.TradingClient(channel);
var mt4 = new MT4.MT4Client(channel);
var headers = new Metadata();
var connectRequest = new ConnectRequest
{
    Host = "mt4-demo.roboforex.com",
    Password = "ehj4bod",
    Port = 443,
    User = 500476959,
};
var reply = connection.Connect(connectRequest, headers);
Console.WriteLine("Response: " + reply);
var summaryReq = new AccountSummaryRequest()
{
    Id = reply.Result
};
var res = mt4.AccountSummary(summaryReq);
Console.WriteLine("AccountBalance: " + res.Result.Balance);
channel.ShutdownAsync().Wait();

Leave a Reply