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.
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.
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 restart a crashed 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 add a stop condition.
Build a multi-take-profit exit¶
Have the assistant plan a partial exit that closes a position in three steps at three take-profit levels, using the position close-partial command.
Open position <position-id> on account <account-id> trades <symbol>. I want a
multi-take-profit exit that closes one third at <tp-1>, another third at
<tp-2> and the final third at <tp-3>. Write a sequence of cTrader CLI
`position close-partial` commands (or one of them plus an `order place-market`
entry), one per take-profit level, with the matching `--volume` for each. Show
every command in order, no preview output.
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.
Warning
An AI assistant is a helper, not an authority. Responsibility for every command that runs against your account remains with you.