Claude Code Trading Bot: Automating a Forex Method
Some links on this page are affiliate links: if you sign up through them, we may earn a commission at no extra cost to you.
A Claude Code trading bot, in the way our founder Stefano Mastria uses the idea, is not a robot that decides what to trade. It is a set of automated strategies whose code was written by Claude Code, Anthropic’s AI coding assistant, from rules he described in plain language, while the decisions and the risk limits stay human. Stefano is an Italian Forex trader, active full time since 2009, who spent years failing to automate his method with human developers. This article tells how it finally worked, what the system looks like in three parts, and where the limits and risks are.
Nothing here is investment advice or a promise of profit. Backtests are simulations, and neither they nor a handful of good live trades guarantee future results.
What is a Claude Code trading bot, really?
Claude is Anthropic’s AI. A trader can use it in a chat window, to ask questions about a method or stress-test an idea, or through Claude Code, which works directly on the files of a project and writes code. According to Anthropic’s own product page, Claude Code is an agentic coding tool that you can steer from a terminal, an IDE or the web. For a trader, that means one thing: you describe what you want in words, and the tool produces the files.
That is also why the phrase “trading bot” needs care. In this setup Claude Code does not open positions and does not forecast where price will go. It produces configuration files, fixes compilation errors, builds a control dashboard and an analysis platform. The orders are sent by automatic strategies running on MetaTrader, following rules Stefano defined. The AI is the builder, not the trader.
Why did fifteen years of attempts at automation fail?
The goal was always the same: take a method applied by hand and let software do the parts a human cannot, such as scanning markets around the clock, operating in hours when the trader is asleep, and executing without fatigue or emotion. Stefano tried hiring professional developers to build custom Expert Advisors and worked with other traders, spending thousands of euros without a usable result.
The cause was not a lack of technical skill. It was language. He thinks in doji bars, reaction points and developing trends; developers think in variables, loops and if-else conditions. A request such as “recognise a trend bar followed by a reaction bar on a key point” produced weeks of discussion and code that did everything except what he meant.
How did Claude Code finally understand the method?
Sceptical after those failures, Stefano opened Claude Code and did what he had done many times before: he described his trading. While he was explaining how he reads a bar from its open, high, low and close to judge whether market pressure is bullish or bearish, the assistant replied, in substance, “are you describing the doji bar?” It had recognised the technical concept behind his words, without asking him to simplify anything.
The lesson is practical rather than magical. The value of a tool like this is not that it knows a secret strategy; it is that it can translate a trader’s vocabulary into code. It still needs a clear method on the human side. If the rules in your head are vague, the code will be vague too, and a precise translation of a bad idea is still a bad idea.
How does a Claude Code trading bot fit a hybrid approach?
The common thread is the method: small, controlled costs per attempt and the chance of a large gain when a trend develops, as explained in risk reward in trend following. Automation does not change that philosophy; it lets the same discipline run on more markets and more hours than one person can follow.
What are the three parts of the system?
1. The control dashboard
The heart of the system is a dashboard that Stefano had sketched on paper more than ten years ago and never managed to build. Once he could describe it to Claude Code, a working version took a few weeks. It tracks each strategy month by month and calculates profits, costs and drawdown. If a strategy reaches the monthly profit target, it blocks new orders for the rest of the month. If drawdown passes a threshold, it pauses the strategy until he has analysed what went wrong. It also holds a calendar of days when the strategies must not trade, for example around high-impact events.
This layer matters most for risk. A strategy with a large drawdown in backtest can be run far more conservatively simply by stopping new orders when losses accumulate. It is a risk control, not a profit engine, and it cannot remove losses; it can only limit how far they run.
2. The analysis platform
One metric Stefano watches closely is what he calls the path to profit: starting from the last winning trade, the platform adds up all the small losses until the next winner, giving the cost of one cycle. If cycles get longer than usual, something has changed in the market or in the strategy, and it is time to intervene.
3. The quantitative research engine
The search for strategies itself is done with StrategyQuant, which needs heavy computing power, so it runs on virtual machines in the cloud (Amazon Web Services) at a significant monthly cost. Claude Code prepares the configuration files that describe what to look for: market, time window, timeframe, risk criteria. When the generated strategies contain compilation errors, which happens often, the code goes back to Claude Code to be fixed. Stefano describes the process as a dialogue rather than programming, and says he has no programming skills of his own.
Strategies found this way are raw material. Within the community they are backtested on about 9.5 years of Darwinex data and then, only if they hold up, tested on research accounts before anything reaches production.
What has it produced so far?
The project has run for about a year and a half and is still unfinished. One example from the founder is a strategy, numbered 4.3.124, that trades gold against the US dollar in a morning window he could never cover by hand. In February 2026 it opened a position on its own with an initial risk of 300 dollars, rode a trend for a few days while keeping the intermediate costs small, and closed at about 2,800 dollars without any intervention.
It would be easy to oversell this, so it is worth being blunt: it is one trade, picked because it illustrates the logic. It says nothing about the next trade, and the same strategy will also have many small losing attempts, which is exactly the cost the trend following approach accepts. For that reason the dashboard, not any single result, is the real centre of the system. For a deeper look at the time horizons these strategies work on, see our piece on short and long term trend following.
What are the limits and risks of a Claude Code trading bot?
Anyone tempted by the idea should read this section twice.
Code that runs is not code that is correct. An AI can produce a strategy that compiles and trades but does not follow your rules. Every output must be checked, ideally on a demo or small research account first.
Backtests mislead. A strategy found by searching thousands of combinations can simply be over-optimised on past data and fail at the first contact with the live market. Past performance guarantees nothing.
Automation amplifies mistakes too. A software error or a wrong parameter can repeat a loss many times, 24 hours a day. This is why limits on drawdown, on monthly results and on trading days sit above the strategies.
The method comes first. Without a real understanding of how prices move, no automation works. Claude Code speeds up the building; it does not supply the edge, the judgement or the discipline.
Costs and dependence. Serious research needs computing power, which is expensive, and relying on a single AI model or provider is a risk in itself.
How can you start building your own?
A sensible order, without any code at first: write your method down as precise rules (what you look at, when you enter, where the stop goes, when you stay out); ask Claude to find ambiguities in those rules; turn them into a simple strategy; and test it on historical data before risking anything. In our community, Stefano shares the strategies and tools he builds, members test them on their own accounts and the data is analysed together; it is described as a research lab, not a course selling a ready-made system. You can find more in the eBook and community page.
Frequently asked questions
Can you build a trading bot with Claude Code without programming skills?
Stefano says he has no programming skills and builds with Claude Code by describing what he wants in words. You still need a clear method and the patience to verify every result before trusting it.
Does Claude trade for you?
No. Claude Code writes and fixes code; it does not open positions or predict prices. Orders are sent by automatic strategies on MetaTrader with rules defined by the trader, under limits set in the dashboard.
Can Claude Code work with TradingView?
The simplest route is Pine Script, the language TradingView provides for building indicators and strategies that can be backtested. You describe the indicator you need, ask Claude Code to write the script, paste it into the Pine Editor on TradingView and check it on the chart before relying on it. As with any AI-written code, the verification is on you.
Is a Claude Code trading bot profitable?
There is no honest general answer. Results depend on the method, the markets, costs and risk controls, and backtests do not guarantee future performance. Trading carries a real risk of losing capital.
This content is for education and information only and documents an ongoing research project. It is not financial advice or an invitation to trade. Figures are indicative; backtest results are simulated and do not guarantee future returns.
