npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

mt4manager

v0.1.7

Published

Node.js native addon starter for MetaTrader 4 Manager API

Downloads

85

Readme

mt4manager

TypeScript-friendly Node.js bindings for the MetaTrader 4 Manager API.

mt4manager lets you use the MT4 Manager API from JavaScript/TypeScript without writing C++ directly.

Built as a native Node.js addon using Node-API (node-addon-api), it provides a modern async API for brokerages, internal tools, and MT4 infrastructure services.


Features

  • Native Node.js addon powered by Node-API
  • TypeScript-first developer experience
  • Runtime DLL loading (mtmanapi64.dll)
  • Async MT4 connection lifecycle
  • Real-time pumping/event updates
  • User management
  • Symbol management
  • Transactions API
  • Positions API
  • Event subscriptions
  • One MT4 native client per manager instance
  • Windows-focused MT4 integration

Status

Beta — APIs may change before v1.0.0.

This project is actively under development and intended for:

  • brokerages
  • prop firms
  • internal tooling
  • automation systems
  • MT4 infrastructure services

Installation

npm install mt4manager

Requirements

Operating System

  • Windows x64

Runtime

  • Node.js >=20
  • Recommended: Node.js 22

MetaTrader Manager DLL

This package does not include:

  • mtmanapi.dll
  • mtmanapi64.dll

You must provide your own licensed MT4 Manager API DLL.

Example:

./dll/mtmanapi64.dll

Development Requirements

Building the native addon from source requires:

  • Windows
  • Node.js >= 20
  • Python 3
  • Visual Studio 2022 Build Tools
    • Desktop development with C++
    • MSVC v143 toolset
    • Windows SDK
  • node-gyp

Install node-gyp:

npm install -g node-gyp

Quick Start

import { createMT4Manager } from "mt4manager";

const manager = await createMT4Manager({
  dllPath: "./dll/mtmanapi64.dll",
  server: "server.com:443",
  login: 9707,
  password: "password",
  pump: true,
});

// listen for user updates
manager.users.on("update", (user) => {
  console.log("User updated:", user);
});

try {
  // get user
  const user = await manager.users.get(123456);

  // update user
  await manager.users.update(123456, {
    name: "New Name",
  });
} finally {
  // cleanup
  await manager.close();
}

API Overview

Users

Get User

const user = await manager.users.get(123456);

Update User

await manager.users.update(123456, {
  name: "Updated Name",
});

Create User

const user = await manager.users.create({
  group: "demotest",
  name: "John Doe",
  email: "[email protected]",
});

User Updates (Pump Events)

manager.users.on("update", (user) => {
  console.log(user);
});

Symbols

Get Symbol

const symbol = await manager.symbols.get("EURUSD");

Get All Symbols

const symbols = await manager.symbols.getAll();

Subscribe to Tick Updates

await manager.symbols.subscribe("EURUSD");

manager.symbols.watch("EURUSD", (symbol) => {
  console.log(symbol.bid, symbol.ask);
});

Transactions

Deposit

const tx = await manager.transactions.deposit({
  login: 123456,
  amount: 100,
  comment: "Initial deposit",
});

Withdrawal

const tx = await manager.transactions.withdrawal({
  login: 123456,
  amount: 50,
  comment: "Client withdrawal",
});

Credit In

const tx = await manager.transactions.creditIn({
  login: 123456,
  amount: 25,
  comment: "Bonus credit",
});

Credit Out

const tx = await manager.transactions.creditOut({
  login: 123456,
  amount: 25,
  comment: "Remove bonus",
});

Get Transaction

const tx = await manager.transactions.get(100000);

Positions

Open Market Position

import { TradeCommand } from "mt4manager";

const trade = await manager.positions.open({
  login: 123456,
  symbol: "EURUSD",
  cmd: TradeCommand.Buy,
  volume: 1,
  comment: "open-position",
  price: 1.17,
});

Close Position

await manager.positions.close({
  id: trade.id,
  volume: trade.volume,
  price: trade.openPrice,
});

Modify Position

await manager.positions.modify({
  id: trade.id,
  sl: 1.1,
  tp: 1.2,
  price: 1.17,
});

Modify Position Comment

await manager.positions.modifyComment(trade.id, "updated-comment");

Open Pending Order

const pending = await manager.positions.open({
  login: 123456,
  symbol: "EURUSD",
  cmd: TradeCommand.BuyLimit,
  volume: 1,
  comment: "buy-limit",
  price: 1.0,
});

Cancel Pending Order

await manager.positions.cancel(pending.id, pending.cmd);

Close Opposite Positions By Ticket

const buy = await manager.positions.open({
  login: 123456,
  symbol: "EURUSD",
  cmd: TradeCommand.Buy,
  volume: 1,
  price: 1.17,
});

const sell = await manager.positions.open({
  login: 123456,
  symbol: "EURUSD",
  cmd: TradeCommand.Sell,
  volume: 1,
  price: 1.17,
});

await manager.positions.closeBy(buy.id, sell.id);

Close Multiple Opposite Positions

await manager.positions.closeMultipleBy(123456, "EURUSD");

Listen For Pumped Trade Events

manager.positions.on("add", (trade) => {
  console.log("Position opened:", trade);
});

manager.positions.on("update", (trade) => {
  console.log("Position updated:", trade);
});

manager.positions.on("delete", (trade) => {
  console.log("Position closed:", trade);
});

Pumping

Pumping mode enables real-time updates from the MT4 server.

Example:

const manager = await createMT4Manager({
  pump: {
    ticks: true,
  },
});

Real-time updates are automatically emitted through module event handlers.


Environment Variables

Only needed for local development and tests. Consumers can pass config directly in code.

Example .env:

MT4_SERVER=server.com:443
MT4_LOGIN=9707
MT4_PASSWORD=abc123
MT4_DLL_PATH=./dll/mtmanapi64.dll
MT4_USER_LOGIN=100010
MT4_TEST_GROUP=demotest

Development

Install Dependencies

npm install

Build

npm run build

Rebuild

npm run rebuild

Run Tests

npm test

Project Structure

src/
native/
include/
build/
dist/
test/

Native Architecture

mt4manager is built using:

  • Node-API (node-addon-api)
  • C++
  • TypeScript
  • node-gyp

The project uses:

  • thread-safe JS callback bridges
  • native MT4 client wrappers
  • async-safe event forwarding
  • runtime DLL loading
  • modular MT4 service wrappers

Example native wrapper:

bridge_->CallJs(UserPayload{*user, type}, BuildUserArgs);

This architecture allows MT4 pump events to safely propagate from native C++ threads into JavaScript event handlers.


Important Notes

MT4 Licensing

Review MetaQuotes licensing terms before deploying or redistributing MT4 Manager API components.

Live Trading Warning

This package can perform:

  • deposits
  • withdrawals
  • credits
  • user modifications
  • position operations

Use carefully on production MT4 servers.


Publishing

Before publishing:

npm run clean
npm run build
npm test
npm run pack:check
npm version patch
npm publish

Current Coverage

  • Users
  • Symbols
  • Transactions
  • Positions
  • Pumping/event updates
  • Native async wrappers
  • TypeScript support

License

MIT


Repository

GitHub:

https://github.com/GilSokolov/mt4manager