What's New in cTrader Automate API 3.01

What's New in cTrader Automate API 3.01

cTrader Automate (former cAlgo) implemented a new set of API in the version 3.01.
Using the new API you can configure the chart, where a cBot or an Indicator is running: get or set the chart settings, chart colors, scroll the chart positions, subscribe to the chart changes events, etc.
Also, we have added a new API to work with the objects that you can draw on the chart, like Trend Lines, Fibonacci Retracement, and others. Now you can draw all the chart objects available in cTrader, get existing objects from the chart and set their properties, receive events when the objects are added, removed, updated, hovered, or selected.

Here is the list of all the changes.

Chart Settings

Bars on the chart

Size and scroll position

Chart events

Chart Objects

There are 14 chart objects available via the new cAlgo API:

For each object, there is a corresponding method of drawing this particular object on a specific chart area.
Here is how to draw a horizontal line and make it interactive for a user:

var line = Chart.DrawHorizontalLine("my line", Symbol.Ask, Color.Red);
line.IsInteractive = true;

Calculate price of trend line

Now you can calculate a price value or indicator value of a trend line for a specific bar index or DateTime:

var line = Chart.DrawTrendLine("myLine", MarketSeries.OpenTime.Last(10), MarketSeries.High.Last(10), MarketSeries.OpenTime.LastValue, MarketSeries.High.LastValue, Color.Red);
line.ExtendToInfinity = true;
var price = line.CalculateY(MarketSeries.OpenTime.LastValue.AddHours(1));
Print("Next bar price is {0}", price);

Interactivity of ChartObject

The IsInteractive property has been introduced to the Chart objects. It allows creating interactive and non-interactive objects.
Non-interactive objects can't be changed by a user and are not visible by other cBots or Indicators. Only a cBot or an Indicator that owns non-interactive object can see it.
Interactive objects, on the other hand, can be seen and changed by a user or other cBots or Indicators that are working on the same chart.
When a cBot is stopped, or an Indicator is removed from the chart, all the non-interactive objects that belong to that cBot or Indicator will be removed from the chart automatically.

Chart API support in Optimization

Note that the Chart API is not supported in Optimization. If you call any methods from the Chart interface, the optimization will be stopped with the 'Not Supported' error.
If you plan to use a cBot or an Indicator in the Optimization, then you should avoid using the Chart interface in this mode. The mode can be checked using the new RunningMode property:

if (RunningMode != RunningMode.Optimization)
{
    Chart.DrawTrendLine...
}

New Color class

The new Color class replaces the old Colors enumeration. Now you can specify the custom colors for indicators, chart objects, and chart color settings.
Color values can be set using RGB, ARGB, Hex string or using a color name.

Indicator line color

For the Indicator lines, we have implemented a new LineColor property in OutputAttribute. Before, only colors from the Colors enum were supported and the line color could be set like this:

[Output("Main", Color = Colors.Red)] 


The new LineColor property can be specified using the Hex value:

[Output("Main", LineColor = "#FF0000")] 


Or color name:

[Output("Main", LineColor = "Red")] 

Trading API shortcuts

For the Position and PendingOrders, we have added the shortcuts for modification and close/cancel methods. Now, most of the modification or close/cancel actions can be done by calling the methods directly on the Position and PendingOrder instance. Find the full list of the new methods below.

For Position:


For PendingOrder:

Deprecated API