Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Google Sheets

Google Sheets can read an MT5 account through Apps Script, which calls the FiveSocket REST API from Google's servers. There is no add-on to install and no file to export from MetaTrader. The script below fills three tabs: the balance, the open positions and the trades closed in the last 30 days.
For the overview, including the same data in a web app, see MT5 account data in Google Sheets or a web app.

Before you start

  • An MT5 account linked in FiveSocket. See the quickstart.
  • An API key with only the accounts:read and data:read scopes. A sheet never needs trading:execute.

1. Store the key in the script's properties

In the sheet, open Extensions → Apps Script. Under Project Settings → Script Properties, add a property named FIVESOCKET_KEY with the key as its value. A script property stays out of the cells and out of the code, but anyone who can edit the script can read it, so use a read-only key.

2. Paste the script

const BASE = "https://api.fivesocket.com/v1" function fivesocket(path) { const key = PropertiesService.getScriptProperties().getProperty("FIVESOCKET_KEY") for (let attempt = 0; attempt < 6; attempt++) { const response = UrlFetchApp.fetch(BASE + path, { headers: { Authorization: "Bearer " + key }, muteHttpExceptions: true, }) const status = response.getResponseCode() if (status === 200) { return JSON.parse(response.getContentText()) } if (status !== 202 && status !== 429 && status !== 503) { throw new Error("FiveSocket " + status + ": " + response.getContentText()) } const headers = response.getHeaders() const wait = Number(headers["Retry-After"] || headers["retry-after"] || 5) Utilities.sleep(Math.min(wait, 30) * 1000) } throw new Error("FiveSocket did not answer in time") } function writeTab(name, rows) { const book = SpreadsheetApp.getActiveSpreadsheet() const sheet = book.getSheetByName(name) || book.insertSheet(name) sheet.clearContents() sheet.getRange(1, 1, rows.length, rows[0].length).setValues(rows) } function refreshAccount() { const accountId = fivesocket("/accounts").data[0].id const account = "/accounts/" + accountId const balance = fivesocket(account + "/balance") writeTab("Balance", [ ["Balance", "Equity", "Margin", "Free margin", "Currency", "Read at"], [Number(balance.balance), Number(balance.equity), Number(balance.margin), Number(balance.marginFree), balance.currency, balance.observedAt], ]) const positions = fivesocket(account + "/positions").positions writeTab("Positions", [ ["Symbol", "Side", "Volume", "Open price", "Current price", "Profit", "Opened at"], ...positions.map((p) => [p.symbol, p.side, Number(p.volume), Number(p.openPrice), Number(p.currentPrice), Number(p.profit), p.openedAt]), ]) const rows = [["Closed at", "Symbol", "Side", "Volume", "Close price", "Profit", "Commission", "Swap"]] let query = "?limit=1000&to=" + encodeURIComponent(new Date().toISOString()) while (query) { const page = fivesocket(account + "/trades" + query) for (const t of page.data) { rows.push([t.closedAt, t.symbol, t.side, Number(t.volume), Number(t.closePrice), Number(t.profit), Number(t.commission), Number(t.swap)]) } query = page.nextCursor ? "?limit=1000&cursor=" + encodeURIComponent(page.nextCursor) : null } writeTab("Trades", rows) }
Run refreshAccount once from the editor and approve the two permissions Google asks for: connecting to an external service and editing this spreadsheet.
What the script relies on:
  • GET /v1/accounts lists linked accounts. The script takes the first one; put an account ID in its place to choose another.
  • Money, prices and volumes arrive as decimal strings, so the script converts them with Number for charts and formulas.
  • GET /v1/accounts/{accountId}/trades needs to. Without from it covers the 30 days before to, and a window can be at most 90 days. A cursor request carries no from or to.
  • 202 account_warming means the session is logging in to your broker. The script waits for Retry-After and repeats the read.

3. Refresh on a timer

In Apps Script, open Triggers → Add Trigger, choose refreshAccount, Time-driven, and an interval such as every 15 minutes. Each run makes four requests when the trades fit one page. Requests count toward your plan's per-minute limits and, before a trial starts, toward the free usage allowance. See errors and limits.

Limits

  • The sheet shows the account as of the last run. FiveSocket has no stream and pushes nothing, so a sheet cannot update tick by tick.
  • This page uses a timed function, not a formula typed into a cell, so the sheet refreshes on a schedule you set and each run is a known number of requests.
  • Sheets is read-only here by design. To place orders from automation, see n8n or the Python quickstart.