Creating and Running cBots¶
Read our dedicated cTrader Algo guide on how cBots operate.
The entire flow of creating and running a cBot is showcased in a comprehensive diagram in another article.
1. To create a new cBot, click on the 'New cBot' button located above the collapsible algorithm lists.
Input the name of your algorithm.
Note
If you want to create an algorithm similar to one of the sample cBots, simply use the 'Duplicate' functionality in the algorithm actions menu.
2. Now, you can edit the sample code in the code editor window to the right of the sidebar.
Developing cBots, you can use our code snippets.
Refer to the 'References' section of the cTrader Algo guide to learn more about the classes, methods, and properties you can use when coding cBots. In addition, you can always choose to write custom methods as shown in our introduction to C# and .NET.
3. Save your cBot by clicking on the 'Save' button above the code editor window, in the context menu, or use the Cmd+S hotkey.
Click on the 'Build' button above the code editor window, to the right of your algorithm, or in the algorithm actions menu. Alternatively, you can use the Cmd+B hotkey.
You will see the following message in the 'Build Result' window after your cBot is built successfully.
4. To add an instance in the cTrader Algo application, press the '+' icon to the right of the cBot in the algorithm list.
You can also add instances via the menu of cBot actions.
In the 'Trade' application, you can add cBots on the active chart via the Chart Toolbar functionality.
5. Before running an instance, adjust your cBot parameters (if needed) in the 'Parameters' section below the trading chart. You can also open and save parameters by clicking on the corresponding buttons in the top right corner of this section.
If you run a cBot from the 'Trade' application, you will be able to customise its parameters in a separate window.
6. Finally, run the cBot instance by clicking on the green 'Start' button to the right of the instance in the algorithm list. Here, you can also adjust the symbol and the time frame.
Or click on the 'Start' button at the top of the trading chart.
To stop the cBot, press the orange 'Stop' button located in the same places.
Warning
You cannot change the symbol, timeframe, and parameters of a running instance. First stop your cBot and then make adjustments.