What's New in cTrader Automate API 4.0

Created at 27 Jan 2021, 09:51
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
Spotware's avatar

Spotware

Joined 23.09.2013

What's New in cTrader Automate API 4.0
27 Jan 2021, 09:51


Dear traders,

We are happy to announce cTrader Automate API 4.0 which is included in cTrader Desktop 4.0. cTrader Automate API 4.0 includes the following new features.

To improve keyboard interaction in cTrader Desktop 4.0, all chart views now always contain one chart that is marked as active. Such a chart will handle all chart related hotkeys such as Space to open search, or Up and Down arrow keys to change charts period.


With this improvement cBots and indicators now can handle keyboard events with a few restrictions:

 

  • Keyboard events will be raised only for cBots and indicators from the active chart
  • If key or keystroke was handled by cTrader as a hotkey, it will not be passed to cBots and indicators
Below you can find two ways to handle keyboard events.

Chart.KeyDown event
This event will be raised for every keyboard event when a single key or a keystroke with modifier keys (Ctrl, Alt, and Shift) was pressed.
Events that are handled as hotkeys by cTrader will not be raised for cBots and indicators.

protected override void OnStart()
{
    Chart.KeyDown += Chart_KeyDown;
}

private void Chart_KeyDown(ChartKeyboardEventArgs obj)
{
    Print("KeyDown: ", obj.Key);
}

Chart.AddHotkey method
The second way to handle keyboard events is a simplified solution to assign a custom hotkey for some action.
Using Chart.AddHotkey method you can set a hotkey for an action using Key enumeration or using a string like "Ctrl + R".
This method will return false if such hotkey is already in use in cTrader, or if another cBot or indicator already uses the same custom hotkey.

protected override void OnStart()
{
    var hotkeyAdded = Chart.AddHotkey(Buy, "Ctrl + Up");
    Print("Hokey was added: ", hotkeyAdded);
}

private void Buy()
{
    Print("Buying using hotkey");
    ExecuteMarketOrder(TradeType.Buy, SymbolName, Symbol.VolumeInUnitsMin);
}

 

Chart activation and deactivation
To check if the chart is active and will receive keyboard events you can use Chart.IsActive boolean property.
You can also subscribe to Chart.Activated and Chart.Deactivated events.

Selected drawings
In the previous version, only a single drawing could be selected. cTrader 4.0 allows selecting multiple drawings. All drawings can be selected using Ctrl + A hotkey. And drawing can be added/removed to/from the selection using the mouse click with the Ctrl key pressed.
With this change, old ObjectSelectionChanged  event was deprecated and new ObjectsSelectionChanged  event was added.
Old event argument had a single ChartObject property. New event contains two collections ObjectsAddedToSelection  and ObjectsRemovedFromSelection .
Also, now you can use the SelectedObjects  property to get the list of all selected drawings in the main chart area or indicator area.

Drawings added/updated/removed events
ObjectAdded , ObjectUpdated , and ObjectsRemoved  events were deprecated. Old events contained an arguments with a single ChartObject  property.
New events ObjectsAdded , ObjectsUpdated , and ObjectsRemoved  were added, each contains a collection of drawings.
This change allows handling a single event when a user pastes multiple drawings from the clipboard (ObjectsAdded event) or drags multiple drawings (ObjectsUpdated event).

Backward compatibility for old events
All old events are working as before. When an event occurs with multiple drawings, an old event will be raised for each drawing, only if a subscription for such an event exists.


@Spotware
Replies

abotrader
27 Jan 2021, 21:20

Swap in backtesting and optimization and .Net 5.0

Hi,

Thanks for your effort, but I'm waiting for Swap in backtesting and optimization for testing my strategies with cBot (it's too long).

Have you a deadline (estimationb) for cTrader with .Net 5.0?


@abotrader

PanagiotisCharalampous
28 Jan 2021, 08:41

Hi abtraderdemo,

The plan is for Q3 2021.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

abotrader
28 Jan 2021, 14:29

RE:

Thanks,

With the Swap feature also?

Best Regards,

 

PanagiotisCharalampous said:

Hi abtraderdemo,

The plan is for Q3 2021.

Best Regards,

Panagiotis 

Join us on Telegram

 


@abotrader

noppanon
28 Jan 2021, 14:56

RE: .Net 5

PanagiotisCharalampous said:

Hi abtraderdemo,

The plan is for Q3 2021.

Best Regards,

Panagiotis 

Join us on Telegram

If cTrader will be migrated to .net 5.0, is it possible to run cBot on android and/or ios?

Finger cross.

 

Noppanon


@noppanon

claye.weight
04 Feb 2021, 09:09

Hi,

When will this update be push out and available for everyone, not just public beta users?


@claye.weight

PanagiotisCharalampous
04 Feb 2021, 10:22

Hi claye.weight,

There is no hard deadline for this. Whenever the new version is considered stable and ready for release to production environments.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

acrigney
04 Feb 2021, 13:30

RE: backlog for the .net 5 version?

Would you be able to publish your backlog of items?

PanagiotisCharalampous said:

Hi claye.weight,

There is no hard deadline for this. Whenever the new version is considered stable and ready for release to production environments.

Best Regards,

Panagiotis 

Join us on Telegram

 


@acrigney

PanagiotisCharalampous
05 Feb 2021, 08:48

Hi acrigney,

We do not have a list available for publishing at the moment.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

dwalkhul
10 Feb 2021, 00:05 ( Updated at: 10 Feb 2021, 00:08 )

RE:

PanagiotisCharalampous said:

Hi claye.weight,

There is no hard deadline for this. Whenever the new version is considered stable and ready for release to production environments.

Best Regards,

Panagiotis 

Join us on Telegram

Am I correct to assume that the Automate API version will always correspond to the cTrader version number ?
My current live and demo cTrader versions are 3.8, therefore my assumption is

  1. the Automated API version of these two cTraders are also 3.8 (Keydown Events not available)
  2. I am dependent on the Brokers for update to cTrader 4.0 which will include Automate API 4.0

@dwalkhul

PanagiotisCharalampous
10 Feb 2021, 08:23

Hi dwalkhul,

Yes you are correct.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

prosteel1
13 Feb 2021, 20:27 ( Updated at: 13 Feb 2021, 22:05 )

Timeline for Python support

Is there any Timeline estimation for implementing a later version of .Net that would support using Python for Artificial Intelligence cBots?

Previously, Panagiotis and Paul said that 4.0 would implement .Net Core but that got cancelled. 

Current framework is still .Net Framework 4 Client Profile which is extremely old and not compatible with anything current, let alone anything in current use.

Without upgrading to a current .Net Framework I don't see why this version is a major version from 3.8 to 4.0, am I missing something?


@prosteel1

PanagiotisCharalampous
15 Feb 2021, 09:16

Hi prosteel1,

The plan is for v4.2. Hopefully it will come in the summer.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

acrigney
15 Feb 2021, 10:35

RE: Timeline for Python support

Guys you can just upgrade any bot to use .net versions I use .net 4.7.2 but you could use 4.8 if you install the framework.

I have developed a generic ML framework using ML.NET with AutoML. AutoML with Python is so slow its a joke. I have developed generic algos as well and these work in almost all markets and conditions. Although most people build algos that suit specific conditions but dont work very well. But my generic algos work even much better than the ML.

prosteel1 said:

Is there any Timeline estimation for implementing a later version of .Net that would support using Python for Artificial Intelligence cBots?

Previously, Panagiotis and Paul said that 4.0 would implement .Net Core but that got cancelled. 

Current framework is still .Net Framework 4 Client Profile which is extremely old and not compatible with anything current, let alone anything in current use.

Without upgrading to a current .Net Framework I don't see why this version is a major version from 3.8 to 4.0, am I missing something?

 


@acrigney

abotrader
18 Feb 2021, 15:05

RE:

PanagiotisCharalampous said:

Hi abtraderdemo,

The plan is for Q3 2021.

Best Regards,

Panagiotis 

Join us on Telegram

This version will be with .NET 6.0 LTS?

Microsoft publish a preview verion :

 


@abotrader

prosteel1
18 Feb 2021, 18:48 ( Updated at: 21 Dec 2023, 09:22 )

Tick Timeframes now in the Tick Database!

Great to see the Tick Timeframe Names are now in the database so they can be referenced by name. My previous Workaround for this which I only implimented yesterday was to create an array with the index as the hirachy and during Optimisation mode to check if the analysis timeframe had a lower index than the trading timeframe and if it did to do Stop() so it didn't use up time in the optimization. The result was it iterated through all combinations of timeframes where it analysed on longer timeframe and entered on shorter timeframe.

This update means that tick timeframes can be hard coded without having to manually select them by making them a parameter :) When using my multi time frame method which seperates the chart timeframe from the analysis and trading timeframe, Multi time frame optimization is now quite easy! 

 

 

This will likely help a great deal in making the selection of timeframes to use more plastic during a cbot running - changing timeframes while its running based on volatility for eg. :)

 

In 3.8 the right side of the screenshot would show all the timeframes as 1 hour, and the tick timeframes would have to be selected manually for this to work, but because 4.0 now has the names of the Tick timeframes in the database,  they now map correctly rather than defaulting to 1 hour because the names weren't in the database before:)

I'm looking forward to figuring out dynamic Timeframes now :) Great job Spotware! 

I'll try to post an example multi timeframe optimization cbot in the next few weeks that makes use of this upgrade.


@prosteel1