MT4 manager gRPC API Go language client example

Created with Sketch.

MT4 manager gRPC API Go language client example

Table of Contents

MT4 manager gRPC API methods

MT4 manager gRPC API proto file

Ready to run example

Install autogenerated cleint libraries:

go get
go get

Alternatively, use this command for your own libraries' generation, if needed:

docker run --user "$(id -u):$(id -g)" -v `pwd`:/defs namely/protoc-all -f ./$PROJECT/Protos/mt4mng.proto -l go -o ./golib

Put you credentials for mt4 server:

Use commands to run the example:

go build main.go
go run main.go

The script:

package main

import (
    mt4mng ""

func main() {
    config := &tls.Config{
        InsecureSkipVerify: false,
    channel, channelError := grpc.Dial("", grpc.WithTransportCredentials(credentials.NewTLS(config)))
    if channelError != nil {
        log.Fatalf("failed to connect: %v", channelError)
    defer channel.Close()

    mainControllerClient := mt4mng.NewMainControllerClient(channel)
    var connectResponse, connectionError = mainControllerClient.Connect(context.Background(), &mt4mng.ConnectRequest{
        Server:   "",
        Password: "",
        User:     1,
    if connectionError != nil {
        log.Fatalf("gRPC protocol error: %v", connectionError)
    if connectResponse.Error != nil {
        log.Fatalf("Server error: %v", connectResponse.Error.Message)
    id := connectResponse.Result

    var accountsResponse, accountsError = mainControllerClient.AccountsList(context.Background(), &mt4mng.AccountsRequest{Id: id})
    if accountsError != nil {
        log.Fatalf("gRPC protocol error: %v", accountsError)
    if accountsResponse.Error != nil {
        log.Fatalf("Server error: %v", accountsResponse.Error.Message)

    for _, accountId := range accountsResponse.Result {
        var accountResponse, accountError = mainControllerClient.AccountDetails(context.Background(), &mt4mng.AccountDetailsRequest{
            Id:    id,
            Login: accountId,
        if accountError != nil {
            log.Fatalf("gRPC protocol error: %v", accountError)
        if accountResponse.Error != nil {
            log.Fatalf("Server error: %v", accountResponse.Error.Message)

Leave a Reply

Your email address will not be published. Required fields are marked *