- Home
- Forum
- cTrader News & Announcements
- What's New in cTrader Automate API 4.0
What's New in cTrader Automate API 4.0
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
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 eventsObjectAdded
, 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.
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?
RE:
Thanks,
With the Swap feature also?
Best Regards,
PanagiotisCharalampous said:
Hi abtraderdemo,
The plan is for Q3 2021.
Best Regards,
Panagiotis
RE: .Net 5
PanagiotisCharalampous said:
Hi abtraderdemo,
The plan is for Q3 2021.
Best Regards,
Panagiotis
If cTrader will be migrated to .net 5.0, is it possible to run cBot on android and/or ios?
Finger cross.
Noppanon
Hi,
When will this update be push out and available for everyone, not just public beta users?
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
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
Hi acrigney,
We do not have a list available for publishing at the moment.
Best Regards,
Panagiotis
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
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
- the Automated API version of these two cTraders are also 3.8 (Keydown Events not available)
- I am dependent on the Brokers for update to cTrader 4.0 which will include Automate API 4.0