FAQ¶
Getting started with cTrader CLI¶
What is cTrader CLI?
cTrader CLI is a command-line tool that manages account, trading and algo operations directly from a terminal, without opening the cTrader desktop application. You type commands to sign in, read market data, place and manage trades, and run, backtest and optimise cBots.
What do I need before I can run cTrader CLI?
You need a cTrader ID with at least one trading account, the cTrader CLI binary on your PATH, and a cTrader ID credentials file.
How do I install cTrader CLI?
Use a package manager on Windows, macOS and Linux. It downloads the correct build for your operating system. A Docker image is also available, and on Windows the executable ships with the cTrader desktop application.
Is cTrader CLI free?
Yes. cTrader CLI is included with cTrader. You provide your own cTrader ID, a credentials file, and a hosting environment if you run cBots unattended.
Authentication and credentials¶
What are the authentication conventions?
cTrader CLI uses two authentication conventions. The batch convention needs --ctid and --pwd-file; the interactive convention needs --ctid, --password and -q. The two are not interchangeable: batch commands reject --password, and interactive commands reject --pwd-file.
How do I store my password safely?
Save your cTID password in a plain-text file. Keep the file outside shared or version-controlled folders, restrict who can read it and delete it when it is no longer needed.
Which broker should I pick when accounts share a number?
Add --broker=<broker-name> to any command. The flag picks the broker when your cTrader ID has accounts that share a number across brokers.
Commands and workflows¶
What operations does cTrader CLI support?
cTrader CLI operations cover accounts, trading, market data, history, indicators, alerts, cBots and projects.
How do I close part of an open position?
Use position close-partial with --volume set to the amount you want to close, in units of the base currency (or in lots through --volume-type=lots). The command closes that portion and leaves the rest open.
How do I list every period token the CLI accepts?
Run ctrader-cli periods. The command prints every token accepted by --period and --timeframe. Parsing is case-insensitive.
How do I run a cBot on a VPS or cloud server?
Run the cBot inside the cTrader CLI Docker image with the host folder mounted and configuration values passed through environment variables.
cBot lifecycle¶
What .NET version does my cBot need?
The .algo file must be built for .NET 8. Recompile older cBots in the latest cTrader desktop application.
How do I start a cBot from the terminal?
Run ctrader-cli run <path-to-algo-file> --account=<account-id> --symbol=<symbol> --period=<period>. The command is long-running, so use --exit-on-stop if you want the cTrader CLI process to exit when the cBot stops.
How do I stop every running cBot at once?
Open the interactive shell with ctrader-cli, sign in, and run stop all yes. The cTrader CLI process exits when the last instance stops.
How do I pass cBot parameters?
Pass cBot parameters in one of three ways: rely on the cBot's defaults, override one or two values through --ParameterName=value on the command line, or pass a saved .cbotset file as the second positional argument. .cbotset files come from the cTrader desktop application and reuse values across runs.
How do I optimise a cBot's parameters?
Optimise a cBot by running ctrader-cli optimize <path-to-algo-file> --params=<path-to-params-file>, where the JSON parameters file declares which parameters to sweep and which to hold fixed. Use --criteria for standard rankings, or --fitness for the cBot's own GetFitness method.
AI agents¶
Can I use an AI assistant with cTrader CLI?
Yes. cTrader CLI supports two workflows: type and script the commands yourself, or describe goals in natural language and have an AI assistant draft cTrader CLI commands for you to review and run.
What should I review before letting an AI run a command?
Do not let an AI assistant start the long-running run command on its own, and review every AI-generated command before running it against a live account.
Need cTrader support?
Reach out through our official channels to resolve any issues:
- Ask questions and connect with traders, developers and other users in the cTrader Discord community.
- Contact the cTrader support team at support@ctrader.com for technical assistance.
- Browse archived discussions on the cTrader Community forum. While the forum is no longer open for new posts, it is full of helpful answers to common issues.