How to Use cTrader Automate References and Guides¶
cTrader Automate comes equipped with a full set of supplementary materials including extensive documentation (a small piece of which you are reading right now) and educational videos. In this article, we explain how you can use this treasure trove of information effectively - the Automate API has many members, and knowing how to quickly get information on what you need is essential.
Updates to Docs
The Automate API documentation is updated regularly to match new cTrader releases. In some cases, you may see the documentation discussing API improvements that you cannot access in cTrader just yet - you can consider such cases ‘sneak peaks’ of what is to come in future versions of cTrader.
How to Access cTrader Automate Documentation and Guides¶
You can easily find educational materials for the Automate API straight in cTrader Desktop. To do so, open the ‘Automate’ application and select any algorithm. In the column to the right of the code editor window, you should see the Automate API documentation fully integrated inside the platform.
In fact, there is a high chance you may be reading this article while inside cTrader.
Alternatively, you can visit the cTrader Help Center and open the section covering the Automate API. In it, you should see the same interface and structure as you would in regular cTrader Desktop. Last but not least, you can visit our YouTube channel where you can watch video guides covering cTrader algorithms. Note that all of these guides are also available as embedded videos in the Help Center and in the integrated Automate API documentation.
How to Navigate cTrader Automate API Documentation¶
The Automate API documentation contains several essential sections.
C# and .NET Basics. This brief intro to the core principles of C# and .NET is perfect for anyone looking to get started with creating custom algorithms.
cBots/Indicators. These guides cover the process of creating cBots/indicators from scratch and provide several code snippets that you can freely reuse when making your own algos.
Working with cBots and Indicators. This section covers everything related to making working with cTrader algorithms even smoother including using external IDEs, compiling and building, debugging, and thread safety.
API Features. The documentation in this section details how you can work with several major members of the Automate API, most notably network access and local storage. The 'Advanced cBot Operations' and 'Advanced Indicator Operations' guides contain code snippets for complex types of cTrader algos such as nested indicators.
User Guides. This section contains articles and videos that cover how you can perform specific actions (e.g., handling key events in the lifecycle of a custom indicator). This is also where the article you are reading right now is located.
References. The Automate API references contain descriptions of every single API member, meaning that you can read information about what you can get or set via certain properties, the possible values of various enum
s, and what certain methods return. The same information is provided in the code editor window when you hover over a specific API member.
How to Use Code Snippets in Your Algorithms¶
Extensive code snippets are one of the key features of the Automate API documentation. Regardless of the type of algorithms you want to create, there is a high chance that the docs contain code that you can freely reuse. To demonstrate this, we can create a simple cBot that runs almost entirely on code taken from the documentation with some small modifications.
To do that, we will first create a new cBot - as usual, this is done by clicking on the ‘New cBot’ button or, if you cannot see it, opening the dropdown menu at the top of the algorithm list and selecting the same option.
We will create a simple cBot that trades multiple symbols - we want to trade some news and it would be sensible to have an algorithm that trades on all symbols connected to these news.
To do so, we will open the integrated Automate API docs and type ‘multiple symbols’ into its search bar. As shown by the search results, there is a sub-section discussing trading other symbols in the ‘Advanced cBot Operations’ guide. If we click on this specific result, we will immediately be taken to the relevant code snippet as well as some supplementary information. We can immediately copy and paste the snippet into our cBot.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
The information above the code snippet tells us that we can use the Symbols
collection to find the symbols that we want. Suppose the US Treasury is delivering another speech on the interest rate cycle and we want to open ‘Sell’ positions on start for several US-based indices (but not for the symbol to which our cBot is attached).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
On start, our cBot will execute the required operations. Referring to the Automate API docs has allowed us to save a lot of time by reusing existing code and only slightly modifying it to suit our needs.
Summary¶
cTrader allows you to access the Automate API documentation in several different places, most notably within the platform itself. It is an incredibly convenient way to empower your algos - you can simply reuse code snippets from the documentation after introducing the required modifications. We also highly recommend subscribing to our YouTube channel so that you are updated every time we release a new educational video.