MT4 client gRPC NodeJS example

Created with Sketch.

MT4 client gRPC NodeJS example

Table of Contents

Methods browser

You need npm to be installed

Ready to run example

Proto file

Do package installation before app running

 npm install

This example has a dynamic code generation
You can find satic code generation in the typescript example.


'use strict';

const PROTO_PATH = __dirname + '/mt4.proto';
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');

const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
    keepCase: true,
    longs: String,
    enums: String,
    defaults: true,
    oneofs: true,

const mt4grpc = grpc.loadPackageDefinition(packageDefinition).mt4grpc;

function main() {
    const connection = new mt4grpc.Connection(

    const mt4 = new mt4grpc.MT4(

    const subscriptions = new mt4grpc.Subscriptions(

    const streams = new mt4grpc.Streams(

    connection.Connect({ user: 500476959, password: "ehj4bod", host: "", port: 443 }, function (err, response) {
        const error = err;
        const token = response.result;
        console.log('id:', token);

        mt4.AccountSummary({ id: token }, function (err, response) {
            console.log('AccountSummary:', response.result);

        subscriptions.Subscribe({ id: token, symbol: "EURUSD" }, function (err, response) {
            console.log('Subscribe:', response.result);

        var onquote = streams.OnQuote({ id: token });
        onquote.on("data", function (st) {
            console.log("OnQuote message :", st.result);
        onquote.on("end", function () {
            console.log("OnQuote end:");


setTimeout(function () {

2 Responses

  1. Ken Cole says:

    I have been surfing online more than 2 hours today, yet I never
    found any interesting article like yours.
    It’s pretty worth enough for me. Personally, if all website owners and bloggers made good content as you did, the internet will be much more useful than ever before.

Leave a Reply

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