Skip to content

How to Work With .cbotset Files

In this article and the video, we discuss how you can use .cbotset files. You can think of these files as 'containers' for storing and reusing certain instance settings and parameter values for cBots.

Applying and Saving .cbotset Files

The easiest way to start working with .cbotset files is to simply add a new cBot instance. Upon choosing a cBot, cTrader will display the 'Add Instance' window where you will be able to customise its parameters.

Alternatively, you can select an existing instance and access its 'Modify Parameters' window. For cBots, this is done by either double-clicking on an instance and selecting 'Modify Parameters' or simply double-clicking on an instance. Note that changing parameters is only possible if an instance is currently stopped.

To store the current instance parameters in a separate file, click on the 'Save' icon in the upper right corner of the window (highlighted in the below screenshot).

In the file dialogue, input the name of the file and confirm your choice.

Default Naming

By default, the name of the .cbotset file contains the name of your algo as well as the symbol and the timeframe to which the chosen instance is attached.

When working with another instance of the same algo, click on the 'Open' icon (highlighted in the below screenshot) to open the file selection dialogue where you will be able to choose the .cbotset file you have saved earlier.

Upon selecting and opening a .cbotset file, several instance settings will be refreshed to match the values specified in the selected file. These settings include not only parameter values but also the symbol and the timeframe to which the currently selected instance is attached.

If your cBot is currently attached to a chart for another symbol or a chart with a different timeframe than specified in the file, cTrader will display a warning window.

If you choose to continue, the parameter values will be substituted with those from the file. However, the instance will still be attached to its original chart.

Note

If you attempt to open a .cbotset file that was generated for a different algo, cTrader will display an error. The window with the error message will also display the exact parameters specified in the .cbotset file but missing from the algo to which you have attempted to apply the file.

Upon pressing on the 'Run' button, the algo instance will be launched taking into account the settings specified in the file you have just applied. This makes .cbotset files a highly convenient method for ensuring that different instances of the same algo behave exactly the same.

Before proceeding further, we will take a look at how a .cbotset file is structured. While it has a fancy extension, the file can be opened in any plain-text editor such as the basic Notepad. If we open the file, we should see a sequence of key-value pairs as shown below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{
  "Chart": {
    "Symbol": "GBPJPY",
    "Period": "m5"
  },
  "Parameters": {
    "PositionId": "PID",
    "TakeProfit1Enabled": "False",
    "TakeProfit1Pips": "15",
    "TakeProfit1Volume": "1500",
    "TakeProfit2Enabled": "False",
    "TakeProfit2Pips": "30",
    "TakeProfit2Volume": "1000",
    "TakeProfit3Enabled": "False",
    "TakeProfit3Pips": "10",
    "TakeProfit3Volume": "3000"
  }
}

We can easily adjust the values as we see fit, making .cbotset files easily modifiable even outside of cTrader.

Use Cases for .cbotset Files

Using .cbotset files can save a lot of time and effort in the following cases.

  • When you have a set of parameters attained via optimisation and you want to reuse it for new instances of an algo.

As optimisation is all about finding the best parameter values for a given algo, you may want to reuse optimisation results for as many new instances as possible.

To do so, conduct optimisation and select the pass the results of which suit your requirements the most. From here, you have two options for generating the .cbotset file containing the parameter values from the chosen pass.

Option 1: switch to the 'Pass Parameters' tab and click on the 'Save Parameters' button.

Option 2: click on 'Apply' next to the chosen pass and then save the newly applied values via the 'Parameters' tab by clicking on the 'Save' icon.

Afterward, you should be able to freely reuse the file with optimisation results for any of the new instances of the same algo.

  • When your algo has a large number of parameters, making it difficult to configure each new instance 'by hand'.

Consider an example of a cBot with four or more parameters.

It would take a long time to manually specify the required parameter values when creating new instances of such algos. Luckily, the entire process takes seconds when using .cbotset files as you can easily apply any configurations you want to any instances you have or may create in the future.

  • When you have several configurations of parameters each of which achieves different results, and you want to easily switch between them.

Depending on the situation, you may want to create several combinations of parameters that dramatically change how an algo behaves. This is often useful when you have a cBot where take profit/stop loss levels are included as parameters. In this case, you could quickly apply pre-made settings containing various protection mechanisms that correspond to your risk tolerance levels and market conditions.

You may even add several instances of the same algo and apply a different .cbotset file to each one on start, which could be helpful for hedging risks.

Using .cbotset Files With cTrader CLI

You can also use .cbotset files when running cBots in external processes via the cTrader CLI tool. If you are unfamiliar with cTrader CLI but want to learn more, click here.

When using the run command in cTrader CLI, you have a number of configurable options that allow you to specify several mandatory and optional settings, most notably the cBot you would like to launch or the symbol you would like to run it on.

To make sure that your cBot launches with parameters from a certain .cbotset file, simply specify the path to this file immediately after the path to the .algo file containing the cBot. The correct order is shown in the following example.

ctrader-cli.exe run C:\mycoolbot.algo C:\coolbotsettings.cbotset

Following this, you can specify other necessary arguments including your cTrader email (-c={email}), the path to the file containing your password (--pwd-file={passwordFile}), the number of your trading account (--account={account}), and the symbol and timeframe on which the cBot should run (--symbol={symbol} --period={period}).

After you execute the command, the bot will start operating using the parameter values from the chosen file.

Summary

Knowing how to work with .cbotset file is a valuable skill for any algo trader who wants to maximise the performance of their algos. If you want to learn more about algo trading in cTrader, subscribe to our YouTube channel.

Subscribe to our YouTube channel