What's New in cTrader Automate API 4.0

Spotware's avatar

Spotware since: 23 Sep 2013;

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

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.

TRADERS FIRSTâ„¢ Vote for your favorite features: https://ctrader.com/forum/suggestions

abtraderdemo since: 27 Jun 2013;

  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?

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  28 Jan 2021, 08:41

Hi abtraderdemo,

The plan is for Q3 2021.

Best Regards,

Panagiotis 

Join us on Telegram

Head of Community Management at cTrader

abtraderdemo since: 27 Jun 2013;

  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

noppanon since: 17 May 2017;

  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

claye.weight's avatar

claye.weight since: 02 Aug 2019;

  04 Feb 2021, 09:09

Hi,

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

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  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

Head of Community Management at cTrader

acrigney since: 25 May 2017;

  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

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  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

Head of Community Management at cTrader

dwalkhul since: 15 Sep 2018;

  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