Introduction
What's cTrader Automate?¶
cTrader Automate is an integral part of cTrader desktop application, it allows you to extend the capabilities of cTrader desktop by developing custom trading indicators and cBots.
What's a cBot?¶
A cBot is a trading robot, or think of it as a program that runs inside cTrader desktop and allows you to easily execute trading operations or manage them.
With a cBot you have full access to all cTrader charting and trading features.
What's a custom indicator?¶
A custom indicator is another type of extension that you can develop by using cTrader desktop, it allows you to run a program on a cTrader chart with access to price data, chart drawing, account data, and much more.
How to develop a cTrader custom indicator or a cBot?¶
To develop a cTrader custom indicator or a cBot you use C# programming language, and .NET.
You must have a basic understanding of C# and .NET, if you don't you can find lots of free tutorials and video courses on internet for C# and .NET.
Each indicator or cBot will be hosted by cTrader desktop on a separate child process under cTrader desktop main process, and they run on a fully isolated process from cTrader desktop.
Creating your first cTrader custom indicator¶
Let's create a simple moving average indicator, to create a new custom indicator on cTrader follow these steps:
1. Go to "Automate" section on your cTrader desktop:
2. Switch to "Indicators" tab:
3. Click on "New" button, cTrader Automate will create a new custom indicator with some default code on it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
4. Now, let's rename our indicator to "Custom Moving Average", to do that right click on indicator and select "Rename" options:
Then type the new name and press "Enter".
5. Now we have to write the indicator code, clear the default code from indicator and replace it with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
6. Build the indicator by click on indicator build button:
7. Create an instance of indicator by attaching it on a chart:
8. Here is the result:
9. Now you might wondering on how to use this indicator on normal cTrader desktop charts, for that go to cTrader trade section, select a chart, then click on toolbar "Indicators" icon:
Type "Custom Moving Average" on Search text box and it will appear, click on it.
For now don't worry about the indicator code, we will explain it in more detail on Creating and Indicator.
Creating your first cTrader cBot¶
Let's create a simple cBot that:
- Opens a buy position when there is an up or bullish bar/candle
- Opens a sell position when there is a down or bearish bar/candle
- Closes a buy position when there is a down or bearish bar/candle
- Closes a sell position when there is an up or bullish bar/candle
Follow these steps:
1. Go to cTrader Automate:
2. Switch to "cBots" tab:
3. Click on "New" button:
It will create a new cBot with some default code on it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
4. Now, let's rename our cBot to "Bar Buy Sell", to do that right click on cBot and select "Rename" options:
Then type the new name and press "Enter".
5. Now clear all the code from cBot and replace it with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
|
6. Now build the cBot by clicking on "Build" button:
7. To use our cBot we have to create an instance of it, right click on it and select "Add Instance" option from context menu:
8. Now we can either run it on our created symbol instance, backtest it, or optimize it:
9. You can access this cBot also from cTrader desktop Trade section, go to Trade section, there is a cBots icon:
You can add it on a chart and run it.
For now don't worry about the cBot code, we will explain it in more detail on Creating and Running a cBot.