Your Trading Results in Google Sheets, Updated Automatically
A spreadsheet is where many traders do their own thinking: a table of months, a formula for risk, a chart nobody else has. The trouble is getting the numbers in. The usual way is to export a report or a CSV from the platform and paste it, and to do it again every time you want the sheet to be true.
This guide replaces the pasting with a short script. Your Google Sheet asks a free API for the figures of your account and rewrites itself on a timer.
🧭 How It Works
| Piece | What it does |
|---|---|
| Your trading account | Connected to ShowMyTrades once, read-only |
| The ShowMyTrades API | Returns the account as JSON, with the statistics already computed |
| A script in your sheet | Asks the API and writes three tabs: Summary, Daily, Monthly |
| A timer | Runs the script every hour, or as often as you like |
Nothing is installed on your computer, and nothing has to stay open.
✅ Before You Start
- Sign up free and connect your account read-only: MT4 or MT5, cTrader or TradeLocker.
- Note the slug of the account: the last part of the address of its page,
https://showmytrades.com/account/YOUR-ACCOUNT-SLUG. - Create a free Developer API Key under Settings in the dashboard, and copy it at once: it is shown only one time. If the account is published the script also works with no key, but with a key you have a request limit of your own.
📝 Step 1: Paste the Script
In your Google Sheet open Extensions → Apps Script, delete what is there and paste this. Put your slug and your key in the first two lines.
const SLUG = 'YOUR-ACCOUNT-SLUG'
const KEY = '' // your Developer API Key; leave empty for a published account
function updateTradingResults() {
const options = { muteHttpExceptions: true }
if (KEY) options.headers = { Authorization: 'Bearer ' + KEY }
const response = UrlFetchApp.fetch(
'https://showmytrades.com/api/v1/accounts/' + SLUG + '?include=equity_curve,monthly',
options
)
if (response.getResponseCode() !== 200) return // keep the last good data
const account = JSON.parse(response.getContentText())
const book = SpreadsheetApp.getActiveSpreadsheet()
writeTab(book, 'Summary', [
['Account', account.name],
['Platform', account.platform],
['Currency', account.currency],
['Balance', account.balance],
['Equity', account.equity],
['Growth %', account.performance.twr_percent],
['Max drawdown %', account.performance.max_drawdown_percent],
['Updated', new Date()],
[account.attribution.text, account.attribution.url]
])
writeTab(book, 'Daily', [['Date', 'Growth %', 'Balance', 'Equity', 'Drawdown %']].concat(
account.equity_curve.daily_performance.map(day => [
day.date, day.twr_percent, day.cumulative_balance, day.cumulative_equity, day.drawdown
])
))
writeTab(book, 'Monthly', [['Month', 'Profit', 'Return %']].concat(
account.monthly.monthly_performance.map(month => [
month.date, month.monthly_profit, month.monthly_percent
])
))
}
function writeTab(book, name, rows) {
const sheet = book.getSheetByName(name) || book.insertSheet(name)
sheet.clearContents()
sheet.getRange(1, 1, rows.length, rows[0].length).setValues(rows)
}
Save, choose updateTradingResults in the toolbar and click Run. The first time, Google asks you to authorise the script: it needs to call an outside address and to write in this spreadsheet. Then look at your sheet: three new tabs, filled in.
| Tab | What is in it |
|---|---|
| Summary | Name, platform, currency, balance, equity, growth, maximum drawdown, time of the last update |
| Daily | One row per trading day: growth so far, balance, equity, drawdown |
| Monthly | One row per month: profit in money and return in percent |
⏱️ Step 2: Put It on a Timer
In the Apps Script editor open Triggers (the clock on the left) and click Add Trigger.
| Setting | Choose |
|---|---|
| Function | updateTradingResults |
| Event source | Time-driven |
| Type | Hour timer |
| Interval | Every hour |
From now on the sheet refreshes by itself, also when it is closed. Every hour is enough for daily and monthly figures. If you want it faster, a minutes timer works too.
📈 Step 3: Build on Top of It
The three tabs are rewritten at every run, so do your own work in other tabs that point at them.
- A chart. Select the Date and Growth % columns of the Daily tab, then Insert → Chart. It grows as new days arrive.
- Your own formulas. For example, the best month:
=MAX(Monthly!C2:C). Or the number of losing months:=COUNTIF(Monthly!C2:C,"<0"). - More data. Add
by_symboloradvancedto theincludelist in the script to get the results per instrument, the profit factor, the Sharpe ratio and the other risk metrics. The fields are listed in MT4 and MT5 account data as JSON.
The growth in the sheet is a time-weighted return: deposits and withdrawals do not move it. That is the figure a spreadsheet built from a raw export usually gets wrong.
🔐 Two Things About the Key
- Who can see it. The key sits in the script, so anyone who can edit the spreadsheet can read it. Share the sheet as view-only, or keep the script in a copy that only you can edit.
- If it leaks. Revoke it in the dashboard and create a new one. The key can only read: it cannot trade and it cannot change an account.
🤝 What the API Asks in Return
The API is free. On the free plan, wherever you show the data to other people, the line Data from ShowMyTrades goes with it, with its address. The script already writes it in the last row of the Summary tab: keep that row when you share or publish the sheet. On the Pro and Ultra plans the line is optional.
❓ FAQ
Does MetaTrader have to stay open? Not with the investor password: nothing runs on your side. With our Expert Advisor the data flows while your terminal runs.
Can I do the same in Excel? Yes. Excel can read a web address that returns JSON with Data → From Web. For a published account the address in the script is all you need.
Can I have several accounts in one spreadsheet?
Yes. With a key, https://showmytrades.com/api/v1/accounts returns all your accounts in one answer, each with its balance, growth and drawdown: one row per account.
Why not IMPORTDATA or a similar formula?
Google Sheets has no built-in formula that reads JSON. A short script is the reliable way, and it lets you choose when the sheet refreshes.
How many requests can I make? 30 per minute with a free key, 120 on the Pro and Ultra plans. A sheet that refreshes every hour uses one.
Is it free? Yes. Connecting the account and the API cost nothing.
🔗 Related Guides
- MT4 and MT5 account data as JSON: every endpoint and field
- A self-updating trading chart on your website: the same data on your own site
- The monthly returns table explained: how to read what the Monthly tab shows
- A practical guide to tracking your trading performance: what is worth watching in the sheet
Connect your account free, paste the script, and stop exporting CSV files.
MT4 and MT5 Account Data as JSON: a Free API for Your Trading Statistics
MetaTrader has no web API for your own account. How to read the balance, equity, growth, drawdown, monthly returns, closed trades and open positions of an MT4 or MT5 account as JSON, with a free REST API. Examples in cURL, Python and JavaScript.
A Myfxbook API Alternative: Your Trading Account as JSON, With a Key and No Session
Looking for an alternative to the Myfxbook API? A free REST API for MT4, MT5, cTrader and TradeLocker accounts: a read-only key in a header, the whole trade history, statistics already computed. The two APIs compared method by method.