AI workflows for cTrader CLI¶
This article covers using an AI assistant with cTrader CLI, for when you know the goal but not the exact syntax. Describe a task in plain language and the assistant produces a command or script for you to review and run.
Note
For the AI assistant to produce correct commands, point it at the cTrader CLI GitHub repository so it can read the full command reference before drafting scripts.
How AI assistants can help¶
A cTrader CLI workflow benefits from an AI assistant when the goal is plain text and the command is not. The assistant works well for:
- Turning a stated goal into a candidate cTrader CLI command.
- Explaining an unfamiliar command, option or output.
- Suggesting a cause and a fix for an error message.
- Reviewing a
.cbotset,optimizeparameters file or backtest configuration. - Drafting a repeatable script from a sequence of commands you already run by hand.
- Using skills to produce commands more reliably.
Commands vs prompts¶
Keep two things clearly separate.
- A command is text you type into a terminal, such as
ctrader-cli candles --account=<account-id> --symbol=EURUSD --period=h1 --count=200. - A prompt is text you send to an AI assistant, describing what you want. The assistant replies with a command that you then review and run.
Note
The prompts in this article are written to be pasted into an AI assistant. The commands shown in the CLI references are written to be run in a terminal.
Write safe prompts¶
A prompt works best when it gives the assistant enough context and clear limits. Include the following:
- Your objective, stated plainly.
- The relevant context, such as your operating system and the command groups you expect to use.
- An instruction not to invent commands or options that cTrader CLI does not provide.
- An instruction to use the syntax of the current public cTrader CLI.
- A request to state any assumptions it makes.
- A request to flag any information that is missing before it proceeds.
- A request for a safe, reviewable sequence of steps rather than a single combined command.
- Placeholders for values such as paths, account numbers and symbols, so that you do not share real credentials.
General prompts¶
The following example prompts show how to use AI with cTrader CLI.
Explain a command you found¶
Ask the assistant to walk through a command line by line, point out options that look risky and flag anything that looks invented, then direct it to the matching entries for the full option list.
Explain what this cTrader CLI command does, option by option, and describe any
effect it would have on a trading account:
<paste the command here>
If any option looks incorrect or risky, say so. Do not assume options that are
not shown.
Diagnose an error¶
Send the command, the error output and the context so the assistant can suggest the most likely cause and a safe fix, with the periodic troubleshooting flow as the fallback.
I ran this cTrader CLI command:
<paste the command, with credentials removed>
It returned this error:
<paste the error output>
Suggest the most likely cause and a safe way to fix it. List the checks I should
make first. Do not invent commands or options that cTrader CLI does not provide,
and state your assumptions.
Draft a repeatable script¶
Turn a sequence of commands you already run by hand into a script that stops on the first failure and keeps credentials out of the file, drawing on the common command groups.
I run these cTrader CLI commands in order by hand:
<list the commands, with credentials removed>
Draft a script for <operating system> that runs them in sequence and stops if a
command fails. Keep credentials in placeholders or environment variables, not
in the script. Add a comment above each command explaining what it does, and
add a note reminding me to review the script before running it on a live
account.
Trading prompts¶
The following prompts target concrete trading scenarios.
Note
Review before you run any AI-generated command or script:
- Confirm that every command and option appears in the CLI references.
- Check that account numbers, symbols, volumes and prices are correct.
- Run read-only commands first to confirm the setup.
- Run trading commands on a demo account before a live one.
Modify or cancel a pending order¶
Ask the assistant to move a working limit's price, stop loss and take profit, or to cancel the order instead, using the order commands.
Write a cTrader CLI command that changes the price of pending order <order-id>
on account <account-id> to <new-price>, with stop-loss <price> and take-profit
<price>. Tell me how to cancel the same order instead.
Run a cBot from a script¶
Hand the assistant the cBot path and the parameters it needs to start an instance through the run command.
Write a cTrader CLI command that runs <path-to-algo-file> on account
<account-id> with symbol <symbol> and period <period>. Show me how to pass cBot
parameters on the command line and how to make the CLI exit when the cBot stops.
Add protection to an open position¶
Ask the assistant to set a stop loss and a take profit on a position that is running without them, using the position commands.
Position <position-id> on account <account-id> is open on <symbol> with no
stop loss or take profit. Write the cTrader CLI command that sets stop-loss
<price> and take-profit <price> on it. A position has one take-profit level,
so use one `--tp` price. Show the command, no preview output.
Operation details
- Market range is not currently supported for market orders in cTrader CLI. The
--limit-rangeoption applies only to stop-limit orders. - Pending orders placed through cTrader CLI do not expire; expiry (good till date) and stop trigger method selection are currently unavailable.
- cTrader CLI currently cannot set or change trade labels and comments, but it can read and display them when listing positions, orders and trading history. cBots run using cTrader CLI can add labels through their own code. In the cTrader Windows and Mac apps, enable the Label and Comment columns to make both visible in the Trade Watch panel.
- cTrader CLI supports single stop-loss and take-profit levels. Trailing stop loss, break-even protection and multiple take-profit levels are currently unavailable.
Warning
An AI assistant is a helper, not an authority. Responsibility for every command that runs against your account remains with you.