Skip to content

Backtest a forex strategy in Claude or ChatGPT on your own broker's data

Updated 2026-11-23

Yes, for simple rules. Connect your MT5 account through FiveSocket, describe the rule in plain words, and Claude or ChatGPT replays it over your own broker's candles. The answer has the number of trades, the net result in your account currency, maximum drawdown, win rate and the costs paid. It also states its assumptions: historical spread is approximated, and today's swap rates are applied to the whole period. It reads history only and never places a trade. 7-day free trial.

7-day free trial. Paid plans start at $9.99 a month. See pricing

An example conversation

You ask: "Backtest this on my EURUSD H1 from May to the end of October. Buy when the 20 EMA crosses above the 50 EMA and RSI 14 is under 70. Stop at 2 ATR, target twice the risk, risk 1 percent a trade on 100,000. My broker charges 7 dollars a lot round trip."

{
  "accountId": "acc_7Hq2Xv",
  "rule": {
    "symbol": "EURUSD",
    "timeframe": "H1",
    "from": "2026-05-04T00:00:00Z",
    "to": "2026-11-02T00:00:00Z",
    "entries": [
      {
        "side": "long",
        "when": {
          "kind": "all",
          "conditions": [
            {
              "kind": "crossesAbove",
              "left": {
                "kind": "ema",
                "period": 20
              },
              "right": {
                "kind": "ema",
                "period": 50
              }
            },
            {
              "kind": "below",
              "left": {
                "kind": "rsi",
                "period": 14
              },
              "right": {
                "kind": "constant",
                "value": 70
              }
            }
          ]
        }
      }
    ],
    "stop": {
      "kind": "atr",
      "period": 14,
      "multiple": 2
    },
    "target": {
      "kind": "riskMultiple",
      "value": 2
    },
    "risk": {
      "kind": "percentOfBalance",
      "value": 1
    },
    "initialBalance": 100000
  },
  "costs": {
    "commissionPerLotRoundTrip": 7
  }
}

The assistant answers: "Over 3,120 hourly bars the rule took 27 trades and won 9 of them, a 33 percent win rate. It ended down 1,807.90 USD, or 1.8 percent. The largest fall from a peak was 8,836.26 USD, 8.8 percent. Costs came to 2,769.43 USD: 1,260.36 in spread, 773.86 in swap and 735.21 in commission. Before costs the rule was slightly ahead, so costs are what turned it negative. Two cautions: the spread is one stored value per bar, not the real tick spread, and the swap is today's rate applied to all six months. 27 trades is also a small sample."

These figures come from a FiveSocket engine run on generated sample candles, to show the shape of an answer. Your figures come from your own broker's bars and will differ.

What the result contains

Fields in a backtest result
PartWhat it tells you
TradesHow many trades the rule took, how many won and lost, and the win rate.
Net resultThe change in balance in your account currency, and as a percent of the starting balance.
Maximum drawdownThe largest fall from a balance peak, in money and percent.
Gain to loss ratioGross gains divided by gross losses. Above 1 means the winners outweighed the losers.
Costs paidSpread, swap and commission, each in your account currency, and the total.
Equity curveThe balance after trades close, cut down to at most 50 points so the assistant can describe or chart it.
Skipped signalsSignals that were not traded, for example because the minimum lot was too large for the risk you set.
AssumptionsPlain sentences that say how fills, spread, swap, commission and sizing were modelled in this run.

On an account with an FTMO, FundedNext or The5ers program set in FiveSocket, the result also carries an estimate of how the run would have fared against that program: whether equity would have touched the daily or maximum loss floor, or the balance reached the first target, and how close it came. It is an estimate from bar data. While a trade is open it uses the worst price of each bar, so it cannot see ticks or slippage. Swap and any commission you give are taken off only when a trade closes. It does not check news, weekend, minimum-day or consistency rules. A backtest that stays inside the limits can still fail a live challenge. Prop firm accounts and AI

What you can describe

  • One symbol from your broker and one timeframe: M1, M5, M15, H1, H4 or D1.
  • A buy rule, a sell rule or both, each with an optional exit rule.
  • Conditions that compare price, a fixed number, SMA, EMA, RSI, ATR, or the highest or lowest value over a period: above, below, crosses above or crosses below. Up to eight can be joined with all or any.
  • A stop as an ATR multiple, a percent of price or a fixed price distance, and an optional target as a multiple of the risk.
  • Risk per trade as a percent of balance, a starting balance, and your broker's commission per lot if it charges one.

Honest limits

  • Historical spread is approximated. MT5 bars store bid prices and one spread value per bar, so the ask is the bid plus that value. Real spreads move inside the bar and widen around news.
  • Swap uses your broker's current long and short rates for the whole period, and money is converted with the symbol's current tick value. Both were different in the past.
  • Commission is counted only when you give the amount. MT5 does not report it for a symbol.
  • Position size is capped with the account's headline leverage for every symbol. Brokers often give metals, indices and crypto lower leverage, so real size limits can be tighter.
  • Swap is counted at weekday rollovers only. A triple-swap day set to Saturday or Sunday, and swap charged over a weekend, are not modelled.
  • If your broker keeps less history than the range you asked for, the run covers only the bars it has. The result says so and gives the first and last bar, so check those dates.
  • Orders fill at the next bar's open. There are no ticks, so slippage and gaps inside a bar are not modelled. When one bar reaches both the stop and the target, the stop is taken.
  • One run covers at most 50,000 bars, and only as far back as your broker's server keeps history for that timeframe.
  • Drawdown is measured when trades close. A loss inside an open trade that later recovers does not show.
  • It is not the MT5 Strategy Tester. It cannot run an Expert Advisor, custom indicators, trailing stops, partial closes, pending orders or more than one symbol at a time.
  • A backtest describes the past. It does not tell you what a rule will do next, and a rule tuned until its history looks good usually disappoints.

Trading leveraged FX and CFDs carries a high risk of losing money quickly. Try any new setup on a demo account first. FiveSocket connects software to your account, and neither FiveSocket nor an AI assistant's output is investment advice.

Set it up

  1. Link the MT5 account

    Sign in to FiveSocket and link the account with its exact server name. The investor password is enough, because a backtest only reads history.

  2. Add FiveSocket to your assistant

    Add https://api.fivesocket.com/mcp/read for reads only, or https://api.fivesocket.com/mcp if you also want trading tools, then sign in when the assistant asks.

  3. Describe the rule

    Name the symbol, timeframe, dates, entry, stop and risk. Ask the assistant to state the assumptions with the result.

Setup for each assistant is on the MCP page. MT5 MCP server setup

Frequently asked questions

Does a backtest place any trades?
No. run_backtest is a read tool. It reads candles and symbol details and does arithmetic on them. It works on an account linked with the investor password, and it is available on the read-only MCP address.
Where does the price data come from?
From your own broker, through the MT5 account you linked. FiveSocket does not use a third-party price feed, so the bars, the symbol names and the costs are the ones your account trades on.
How far back can I test?
As far as your broker's server keeps bars for the timeframe, up to 50,000 bars in one run. That is about 35 days of M1 bars or about eight years of H1 bars. If the broker returns too few bars for the rule, the assistant is told how many it got.
Can it backtest my Expert Advisor or a TradingView script?
No. It runs rules built from the listed conditions and indicators. It does not run MQL5 or Pine Script code. If your idea fits those building blocks, describe it in words and the assistant writes the rule.
How accurate is it?
It is a bar-by-bar replay with your broker's contract size, current swap rates and stored spread, checked against a reference engine. It is still an approximation: there are no ticks, the spread is one value per bar, and swap rates are today's. Treat the result as a rough filter for ideas, and test on a demo account before you risk money.
How much does it cost?
Plans start at $9.99 a month for one MT5 account. Link your MT5 account and try it free, no card: 24 hours or 100 calls, whichever comes first. Then a 7-day free trial, card required. Cancel anytime. The trial includes one connected MT5 account.

Try it on your own account.

Link your MT5 account and try it free, no card: 24 hours or 100 calls, whichever comes first. Then a 7-day free trial, card required. Cancel anytime. The trial includes one connected MT5 account. Cancel before the trial ends and you are not charged. A demo account is the safest place to start.

7-day free trial. Paid plans start at $9.99 a month. See pricing