How to Build a Trading Bot With ChatGPT or Claude
A trader who has never written code can now describe a futures strategy to ChatGPT or Claude and get back a working script in a few minutes. That part of the job really has become easy. The hard part moved to deciding whether the strategy deserves money, a question no assistant can answer for you and one that only careful testing in simulation starts to settle.
Three Things an Assistant Can Build
A Pine Script strategy for TradingView. This is the route we would point a non-programmer to first. Pine Script strategies run inside TradingView’s broker emulator, which simulates trades on historical and realtime bars, and the Strategy Tester shows the simulated results. Alerts from the strategy then go through a bridge to your broker, so you never write broker code.[1]
A NinjaScript strategy for NinjaTrader 8. A general assistant can write C# NinjaScript, and NinjaTrader now ships its own AI Strategy Builder that turns a plain-English description into a compiled strategy and runs a backtest. Our NinjaTrader automation guide covers that route.[2]
Code that calls a broker’s API directly. The Tradovate API is the usual futures example, and it has entry requirements a chat assistant cannot waive: a live, funded account with a minimum balance, a paid add-on, no real-time market data in the add-on, and no access for prop-firm or evaluation accounts. Our Tradovate automation guide lists them with their dates.[3]
Coding tools that work inside a project folder on your own computer, such as Claude Code, can also write the files, run them and read the error messages themselves. That speeds up the API route considerably. It does nothing for the question of whether the strategy works.
Build It Step by Step
- Write the rules in plain words first. Name the contract (MNQ, for example; MNQ vs NQ explains why the micro suits a first bot), the session it may trade, the entry condition, the stop and target in ticks, the most trades per day and what happens to an open position at the close. A hypothetical set might read: long only, 9:45 to 11:30 a.m. Eastern, a stop of 40 ticks, a target of 60 ticks, at most two trades a day. Those numbers are an example of how specific to be, nothing more.
- Ask for a Pine Script strategy, not an indicator. Only a strategy runs in the Strategy Tester and fires alerts on its simulated fills. Ask for explicit stop and target orders on every entry, and for the strategy to flatten before the session ends.
- Paste it into the Pine Editor, add it to a chart and read the Strategy Tester. When the code throws an error, paste the error back to the assistant. Expect several rounds.
- Set commission and slippage yourself. TradingView’s documentation says that if no commission is specified, “the strategy applies no commission to filled orders.” A futures strategy tested with zero costs will look better than any account can trade it.[1]
- Hold back data you never tuned on. Build and adjust on one stretch of history, then run the finished rules once on a later stretch you did not touch. Our guide to backtests and forward tests explains what each kind of result can and cannot tell you.
- Forward test on a demo account through a bridge. Our page on which TradingView plan you need for webhooks and our TradingView to Tradovate setup guide cover the plumbing. Run it for weeks and compare each demo fill with the chart.
- Set a daily loss limit at the broker before the first live order, so a bug cannot keep trading after a bad morning. Our page on the Tradovate daily loss limit shows where.
What the Assistant Cannot Do
It cannot find you an edge. The CFTC’s customer advisory on AI trading bots says it in five words: “AI technology can’t predict the future.” A language model writes code that follows your rules. It does not know whether those rules make money after costs, and it will write a losing strategy as cheerfully as a winning one.[4]
It will help you overfit if you ask it to. The most tempting loop in AI-assisted building is pasting the backtest back in and asking for better numbers. The assistant will add a filter, tighten a stop, skip a weekday, and the equity curve will improve every time. What you are doing is fitting the rules to the past, and a strategy tuned that way tends to fall apart on data it has not seen. Decide the rules, test them once on held-back data, and treat every later tweak as a new strategy that needs its own untouched test.
It does not see what your account sees. The assistant never watches a fill, a rejected order or a dropped connection. TradingView’s documentation warns that some strategy execution settings can cause repainting or lookahead bias on historical bars, which makes a backtest show trades that could not have happened live. Ask the assistant to explain every setting in the strategy declaration and leave the defaults unless you know why you are changing one.[1]
NinjaTrader’s own AI builder says the same thing about its output: “A generated strategy is a starting point, not a finished system.”[2]
Keep Your Credentials Out of the Chat
Never paste a broker password, an API key or a bridge webhook URL into a chat assistant. Write the code with placeholders and add the real values on your own machine. TradingView’s webhook article tells users not to put login credentials or passwords in a webhook body, and Tradovate’s API article shows an API key once and warns never to expose it in public repositories. A webhook URL from a bridge is effectively a key too, since anyone who has it can send signals to the strategy behind it.[5][3]
When Building Is the Wrong Project
Building your own bot makes sense if you want to own the logic and are willing to spend weeks testing it. If what you actually want is a finished strategy, AutoPilot Trader is one. It is the wrong product for anyone who wants to build a strategy of their own, because its rules are fixed and you cannot change them, and for crypto or stock traders, because it trades CME index futures only. It is rules-based automation rather than AI, and while it runs on prop-firm accounts, we recommend a personally funded cash account for it. Our guide to AI versus rules-based trading bots explains the difference, and our free trading bots guide covers what building yourself actually costs.
Frequently Asked Questions
Can ChatGPT or Claude build a trading bot?
Yes. An AI assistant can write a TradingView Pine Script strategy, a NinjaScript strategy or code that calls a broker's API, even for someone who has never programmed. It cannot tell you whether the strategy has an edge, so test anything it writes in simulation for weeks before real money.
Will an AI-built trading bot make money?
Nobody can promise that, and an AI assistant is no exception. The CFTC's customer advisory says AI technology cannot predict the future. Whether a bot makes money depends on its rules, its costs and its sizing, which only careful testing begins to answer.
Is it safe to give an AI assistant my broker login?
No. Never paste a broker password, an API key or a bridge webhook URL into a chat. Write the code with placeholders and add the real values on your own machine.
Code OPINICUS gets you a discount at checkout.
Sources
- Pine Script docs: Strategies, TradingView. Accessed November 2026. ↩︎
- NinjaTrader 8 Help Guide: Strategy Builder, NinjaTrader. Accessed November 2026. ↩︎
- Tradovate API Access, Tradovate Help Center. Accessed November 2026. ↩︎
- CFTC Customer Advisory Cautions the Public to Beware of Artificial Intelligence Scams (Release 8854-24), CFTC. Accessed November 2026. ↩︎
- How to configure webhook alerts, TradingView. Accessed November 2026. ↩︎
