How to Use cTrader Automate References and Guides¶
cTrader 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 algo API has many members, and knowing how to quickly get information on what you need is essential.
Updates to Docs
The 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 Documentation and Guides¶
You can easily find educational materials 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 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 Centre and open the section covering algo trading. 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 Centre and in the integrated API documentation.
How to Navigate Across Documentation¶
The 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.
Working With Algos. 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 Algo 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 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
enums, 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¶
Extensive code snippets are one of the key features of this 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 Algo 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 Operations With cBots’ 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 API docs has allowed us to save a lot of time by reusing existing code and only slightly modifying it to suit our needs.
cTrader allows you to access the API documentation in several different places, most notably within the platform itself. It is an incredibly convenient way to empower your algos as 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.