Data
MetaTrader 5
@fx-charting/adaptor-mt5 — history, live ticks and symbols from your broker's MT5 server, through the MT5 Web API.
The adaptor is a separate package with two halves. The MT5 Web API needs a manager login and keeps its session on one TCP connection, so a small server part holds both; the browser part is a datafeed that talks to it.
npm i git+https://github.com/salar-kamjoo/fx-chart.git#adaptor-v0.1.1 # branch "adaptor"; or #adaptor for the newest commit
npx fx-charting-adaptor-update # later: update to the newest releaseimport { createMt5ServerFromEnv } from "@fx-charting/adaptor-mt5/server";
export const runtime = "nodejs";
// MT5_HOST, MT5_LOGIN, MT5_PASSWORD, MT5_BUILD in .env — they never reach the browser
const mt5 = (globalThis.__mt5 ??= createMt5ServerFromEnv(process.env, {
authorize: async (request) => true, // check your session here
}));
export const GET = (request) => mt5.handler(request);"use client";
import { FxChart } from "@fx-charting/pro";
import { mt5Datafeed } from "@fx-charting/adaptor-mt5";
const datafeed = mt5Datafeed({ url: "/api/mt5" });
export default () => <FxChart datafeed={datafeed} symbol="EURUSD" interval="15" />;With Express: app.use("/api/mt5", requireAuth, mt5.node).
| What | How |
|---|---|
History | MT5 serves M1 bars; the server builds every interval (1 m … 1 M) from them and pages back as you scroll. |
Live prices | One quote poll for all watched symbols on the server, pushed to the browser over one Server-Sent Events stream. Candles are built from the bid; Bid / Ask lines from the quote. |
Symbols | Search list you choose (or every symbol on the server); digits and type come from MT5. |
Time | Broker server time (GMT+2 / +3) is measured and converted, so everything is UTC. |
EventSource can't send headers. If your API uses a bearer token, pass
mt5Datafeed({ live: "poll", fetchOptions: { headers } }), or authenticate the stream with a cookie.All options, endpoints and MT5 details are in the adaptor's README.