What's New in cTrader Automate API 3.5

Created at 05 Mar 2019, 11:20
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 3.5
05 Mar 2019, 11:20


Dear traders,

We would like to inform you that we have released cTrader Desktop v3.5! Below you can find the new features included in cTrader Automate API 3.5.

Access to all symbols
Now you can get all the symbols available in the platform using Symbols property.
It contains all the symbol names as string values. Also, you can get a Symbol or SymbolInfo by calling dedicated methods.
SymbolInfo contains only information about a symbol, like tick size, dynamic leverage etc.
And Symbol inherits from SymbolInfo and adds real-time quotes update. In this version, the Symbol interface adds a Tick event.

Below is an example of getting all symbol names with 'USD' in their name:

var usdSymbols = Symbols.Where(s => s.Contains("USD"));
Print("USD symbols: ", string.Join(", ", usdSymbols));

This example shows how to subscribe to a tick event for a specific symbol:

var gbpusd = Symbols.GetSymbol("GBPUSD");
gbpusd.Tick += args => Print("{0} {1}/{2}", args.SymbolName, args.Bid, args.Ask);

Also, you can get multiple symbols at once using Symbols.GetSymbols method:

var mySymbols = Symbols.GetSymbols("EURUSD", "GBPUSD", "USDJPY", "USDCHF");

In case you don't need quotes, but only info about the symbol, you can use SymbolInfo interface.
Here is an example of getting all the symbol IDs that are used in FIX API:

var symbols = Symbols.GetSymbolInfos("EURUSD", "GBPUSD", "USDJPY", "USDCHF");
foreach (var symbol in symbols)
    Print(string.Format("{0}, {1}", symbol.Name, symbol.Id));

Symbol parameter replaced with symbolName
All trading methods are changing signatures. The old ones used to have Symbol parameter, now you need to pass symbolName as a string.

For trading with current charts symbol it changes like this:

// Old
ExecuteMarketOrder(TradeType.Buy, Symbol, 10000);

// New
ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000);

For trading with other than current charts symbol:

// Old
var gbpusd = MarketData.GetSymbol("GBPUSD");
ExecuteMarketOrder(TradeType.Buy, gbpusd, 10000);

// New
ExecuteMarketOrder(TradeType.Buy, "GBPUSD", 10000);

Also, symbolName replaces Symbol in the following methods:

  • MarketData.GetMarketDepth
  • MarketData.GetSeries
  • Positions.Find and Positions.FindAll
  • History.FindLast and History.FindAll

Watchlists API
Now it is possible to get all the watchlists and symbols in watchlists. Also you can receive events about watchlist creation/removal/rename and about adding/removing a symbol in watchlists:

Watchlists.WatchlistSymbolAdded += e => Print("User added {0} symbol to '{1}'", e.SymbolName, e.Watchlist.Name);
// User added AUDUSD symbol to 'My Watchlist'

Changing symbol and timeframe on a chart
Added new methods to the Chart interface to change symbol and timeframe:

  • bool TryChangeTimeFrame(TimeFrame timeFrame)
  • bool TryChangeTimeFrameAndSymbol(TimeFrame timeFrame, string symbolName)

For now these methods will take effect only when called from an indicator because running cBot blocks changing symbol and timeframe on the chart.

var result = Chart.TryChangeTimeFrameAndSymbol(TimeFrame.Hour, "GBPUSD");
var message = result ? "Symbol and timeframe changed" : "Failed to change symbol and timeframe";
Print(message);

Bid and Ask properties
Added shortcut properties to Bid and Ask values for current symbol:

Print(Symbol.Bid); // Get current Bid price
Print(Bid); // Shortcut

Input parameters grouping
Input parameters now can be grouped in UI if you set 'Group' property on the ParameterAttribute:

[Parameter("Stop Loss (pips)", Group = "Protection")]
public int StopLossInPips { get; set; }

[Parameter("Take Profit (pips)", Group = "Protection")]
public int TakeProfitInPips { get; set; }

Custom enums for input parameters
Custom enums now can be used as input parameters:

public enum ClosingStrategy {
    StopLoss, TrailingStop, OppositeSignal
}
//...
public class NewcBot : Robot
{
    [Parameter("Closing Strategy")]
    public ClosingStrategy ClosingStrategy { get; set; }
//...

Obsolete methods and properties
Because of the recent changes, the following methods and properties are obsolete:

  • All method overloads that takes Symbol parameter are now replaced with new overloads with a symbolName string parameter.
  • Position.SymbolCode and HistoricalTrade.SymbolCode replaced with SymbolName property.

What to Expect Next
The next version of cTrader 3.6 will bring new features for cTrader Automate:

  • Possibility to add UI controls to a chart. Like text labels, buttons, input fields, images etc.
  • The following information will be available from API:
    • cTrader version.
    • User ID (cTID).
    • Selected color theme and theme change event.
    • Selected UTC offset and change event.
  • Auto restart for cBots which allows running cBot automatically on cTrader start if cBot was not explicitly stopped by a user before a shutdown.

Best Regards,

cTrader Team


@Spotware
Replies

afhacker
05 Mar 2019, 13:32

You forgot the color picker, date time picker, and time picker parameters.

If you allow us to iterate over all open charts and each chart attached indicators, objects, and cBots, that will be a really huge thing and it will open the door for lots of new exciting stuff.

We should be able to remove an indicator/cBot from a chart or start/stop the indicator both via an indicator and cBot (this feature must be available for all chart objects inside "Charts" collection, not just the indicator/cBot current chart).

The other cool feature will be adding a new section to indicator/cBot parameters window that allows the user to change the indicator/cBot time zone, so the programmer will be able to set a default time zone via the Robot/Indicator attributes TimeZone property but the user must be able to change that default time zone on indicator/cBot parameters window, you can add a new section like "Outputs" in indicator parameters window for that.

The Chart object must have a "Close" public method, so whenever you call the method it will close the chart.


@afhacker

trader.calgo
05 Mar 2019, 16:58


it's great! Thanks you


@trader.calgo

.ics
06 Mar 2019, 02:44

Is it already possible to access swaps costs via cTrader Automate API?


@.ics

PanagiotisCharalampous
06 Mar 2019, 10:19

Hi .ics,

No this is not available yet.

Best Regards,

Panagiotis


@PanagiotisCharalampous

darcome
06 Mar 2019, 10:58

Hello,

How can I know exactly what version of cTrader do I have?  For example, yesterday cTrader updated, but if I try to type Symbols on the code editor the intellisense doesn't show me anything, so I suspect the update wasn't about API 3.5... but then what got updated? Is there a way to see the complete changelog of cTrader?

Thanks in advance


@darcome

PanagiotisCharalampous
06 Mar 2019, 11:04

Hi darcome, 

You can see the version of your cTrader on the form's title on the top. 3.5 is only available in Spotware Beta at the moment. You can see what is new in Help > What's New section.

Best Regards,

Panagiotis


@PanagiotisCharalampous

darcome
06 Mar 2019, 11:13

Ah ok, I got confused because nowhere in the main post is written that this is a beta...

But, nonetheless, yesterday my cTrader got an update and I don't have any idea of what has been updated. I am with IC Markets and I already had version 3.3, so I suppose it was a minor update, but I don't have a clue of what has been updated... And I am now conscious that this is not the correct thread for this :(


@darcome

Waxy
07 Mar 2019, 07:01

Thanks for your hard work Spotware,

I have questions,

Why this feature works with custom enums being parametrizable, but not built-in enums like HorizontalAlignment, and others? I hope is available soon also.
Note: Currently I can build a custom enum and then cast to a built-in enum, that's what I can do for now.

Also, will you wait for 3.6 before launching 3.5 as the official version?

Thank you

 


@Waxy

uvwxyz
07 Mar 2019, 13:10

IsOverlay not work as previous version did.

Hi,

Previously one could use in the Indicators opened chart's tool : f / Custom and overlay a custom indicator B ( built with declaration: "IsOverlay = true;) over another custom indicator A (which is already displayed in a panel), by selecting (in the  f / Custom dialouge box)  B as the 'Indicator' and selecting an output series of indicator A as the input series (source) for indicator B.

Now doing so draws the Indicator B on the main chart which is useless, and also takes away a lot of power of cTrader custom indicators. Previously it drew on the panel of Indicator A.

Can you please, make this previously available funtionality available again.

Cheers.


@uvwxyz

PanagiotisCharalampous
07 Mar 2019, 14:03

RE:

Waxy said:

Thanks for your hard work Spotware,

I have questions,

Why this feature works with custom enums being parametrizable, but not built-in enums like HorizontalAlignment, and others? I hope is available soon also.
Note: Currently I can build a custom enum and then cast to a built-in enum, that's what I can do for now.

Also, will you wait for 3.6 before launching 3.5 as the official version?

Thank you

 

Hi Xavier,

Works fine for me

using System;
using System.Linq;
using System.Windows.Forms;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CustomcBot : Robot
    {
        [Parameter()]
        public cAlgo.API.HorizontalAlignment Alignment { get; set; }

        protected override void OnStart()
        {

        }

        protected override void OnTick()
        {

        }
        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
07 Mar 2019, 16:20

RE: IsOverlay not work as previous version did.

uvwxyz said:

Hi,

Previously one could use in the Indicators opened chart's tool : f / Custom and overlay a custom indicator B ( built with declaration: "IsOverlay = true;) over another custom indicator A (which is already displayed in a panel), by selecting (in the  f / Custom dialouge box)  B as the 'Indicator' and selecting an output series of indicator A as the input series (source) for indicator B.

Now doing so draws the Indicator B on the main chart which is useless, and also takes away a lot of power of cTrader custom indicators. Previously it drew on the panel of Indicator A.

Can you please, make this previously available funtionality available again.

Cheers.

Hi abs,

This is a bug and we will fix it.

Best Regards,

Panagiotis


@PanagiotisCharalampous

uvwxyz
08 Mar 2019, 06:50

RE: RE: IsOverlay not work as previous version did.

Panagiotis Charalampous said:

uvwxyz said:

Hi,

Previously one could use in the Indicators opened chart's tool : f / Custom and overlay a custom indicator B ( built with declaration: "IsOverlay = true;) over another custom indicator A (which is already displayed in a panel), by selecting (in the  f / Custom dialouge box)  B as the 'Indicator' and selecting an output series of indicator A as the input series (source) for indicator B.

Now doing so draws the Indicator B on the main chart which is useless, and also takes away a lot of power of cTrader custom indicators. Previously it drew on the panel of Indicator A.

Can you please, make this previously available funtionality available again.

Cheers.

Hi abs,

This is a bug and we will fix it.

Best Regards,

Panagiotis

Hi Panagiotis,

Thanks greatly for such a quick and a well-appreciated reply.

Cheers.


@uvwxyz

bienve.pf
08 Mar 2019, 14:32 ( Updated at: 21 Dec 2023, 09:21 )

Panel of bots

Very good improvements in version 3.5. Grouping parameters in groups and enums is something that was much missed.
I have to say that I have been programming for 2 years with cTrader / calgo and the new presentation of the configuration panel of the bots takes a bad path. You can not change the size (in this way the big titles are lost). On the other hand, clicking every time we change a parameter is a bit tedious especially when we are doing backtesting.

Greetings.


@bienve.pf

bienve.pf
08 Mar 2019, 14:34

It would be very good if it were in a floating window.

One way or another should be optional. I do not know why the previous presentation is eliminated


@bienve.pf

eivaremir
09 Mar 2019, 15:12

Backtesting Options with custom timeframes

I've just written a bot which reads renko graphics, and I want to backtest it but this function isn't available, do you have plans to incorporate it in the future?


@eivaremir

gakazas
10 Mar 2019, 18:40 ( Updated at: 21 Dec 2023, 09:21 )

Hello, Thanks for the update.
"Load Parameters" for a cbot doesn't work when dealing with custom enums, as even if the parameter is saved in the .cbotset file, when loading from it an error message appears and the first option is always selected. 


@gakazas

gakazas
10 Mar 2019, 18:46

part of my cbot:
 

    public enum SignalIndicator
    {
        Option1,
        Option2,
        Option3
    }

    [Robot(TimeZone = TimeZones.CentralEuropeStandardTime, AccessRights = AccessRights.FileSystem)]
    public class myCbot : Robot
    {
        [Parameter("Signal Indicator")]
        public SignalIndicator SigIndi { get; set; }

part of cbotset file:
 

[ChartParameters]
Symbol = EURUSD
Timeframe = D1

[cBotParameters]
password = 0
SigIndi = 1

 


@gakazas

PanagiotisCharalampous
12 Mar 2019, 12:08

RE: Backtesting Options with custom timeframes

eivaremir said:

I've just written a bot which reads renko graphics, and I want to backtest it but this function isn't available, do you have plans to incorporate it in the future?

Hi eivaremir,

Yes this is in our plans. It will be added in one of the upcoming updates.

Best Regards,

Panagiotis


@PanagiotisCharalampous

PanagiotisCharalampous
12 Mar 2019, 12:11 ( Updated at: 21 Dec 2023, 09:21 )

RE:

gakazas said:

Hello, Thanks for the update.
"Load Parameters" for a cbot doesn't work when dealing with custom enums, as even if the parameter is saved in the .cbotset file, when loading from it an error message appears and the first option is always selected. 

Hi gakazas,

Thans for letting us know about this. We will investigate it.

Best Regards,

Panagiotis


@PanagiotisCharalampous

gakazas
13 Mar 2019, 22:52

Please igonre the "password =0" part of the code above, shouldn't be there for the example.
I would also like to suggest to take "Input Parameters Grouping" one step further, and make possible to create Sub-groups as well.


@gakazas

lukas.ourada
14 Mar 2019, 14:47

hi
firstly thanks, good job.
looks good!

me like grouping parametr and custom enums for input parameters, but style of parametr panel is best in old 3.3! 

I don't like to click on a button every time I want to change something !!!

I would also welcome to add parameters to the imput text area. For example, to set the text of notification emails.

and also the tooltip options so I can write a parameter description in the code, and after hovering the mouse the user could read the comment

and the question: when will 3.5 be officially for brokers?

Thanks


@lukas.ourada

... Deleted by UFO ...

... Deleted by UFO ...

... Deleted by UFO ...

PanagiotisCharalampous
18 Mar 2019, 12:08

Hi Lukas,

Thanks for your suggestions, we have forwarded them to the product team. v3.5 will be released to the brokers as soon as we feel is stable enough to be moved to production environments.

Best Regards,

Panagiotis


@PanagiotisCharalampous

Waxy
20 Mar 2019, 19:36

Hello!

Please allow the use of Description Attribute to enums so they could be easily readable, i.e:
 

using System.ComponentModel; 

public enum MyEnum 
{ 
    [Description("value 1")] 
    Value_1, 
    [Description("value 2")]
    Value_2, 
    [Description("value 3")]
    Value_3
}


Thanks for your hard work.


@Waxy

AndreaDev
22 Mar 2019, 22:39

RE:

Panagiotis Charalampous said:

Hi .ics,

No this is not available yet.

Best Regards,

Panagiotis

Hi Panagiotis,

Will the Heikin-Ashi chart be available on the desktop any time soon? I can see it on the web and has been voted a lot, so I was just wondering if you can give us an eta for this feature.

In case you will, is there any plan for Heikin-Ashi  in backtesting?

 


@AndreaDev

gakazas
22 Mar 2019, 22:42 ( Updated at: 21 Dec 2023, 09:21 )

Hi again! Xavier's suggestion is great. I would also like to report a crash that occurs when there is a groups parameter, and I try to add a second one. App crashed as I am typing. 


@gakazas

gakazas
23 Mar 2019, 18:10

For the grouping of the cbot settings, a toggle button to be able to hide the settings of the various groups would be also useful. It would help navigate the needed group in the settings.


@gakazas

jumpycalm
29 Mar 2019, 00:00

RE:

+1 "You forgot the color picker, date time picker, and time picker parameters."

afhacker said:

You forgot the color picker, date time picker, and time picker parameters.

If you allow us to iterate over all open charts and each chart attached indicators, objects, and cBots, that will be a really huge thing and it will open the door for lots of new exciting stuff.

We should be able to remove an indicator/cBot from a chart or start/stop the indicator both via an indicator and cBot (this feature must be available for all chart objects inside "Charts" collection, not just the indicator/cBot current chart).

The other cool feature will be adding a new section to indicator/cBot parameters window that allows the user to change the indicator/cBot time zone, so the programmer will be able to set a default time zone via the Robot/Indicator attributes TimeZone property but the user must be able to change that default time zone on indicator/cBot parameters window, you can add a new section like "Outputs" in indicator parameters window for that.

The Chart object must have a "Close" public method, so whenever you call the method it will close the chart.

 


@jumpycalm

TradeMingZhi
01 Apr 2019, 00:16

Nice update! When will this be in non-beta? my Ctrader isn't showing any updates yet.

is vanishing stop loss glitch fixed btw?


@TradeMingZhi

PanagiotisCharalampous
02 Apr 2019, 11:40

Hi wisegprs,

3.5 will be pushed to brokers as soon as testing is finished and the update is stable and ready for production environments. 

is vanishing stop loss glitch fixed btw?

Can you tell me which discussion are you referring to?

Best Regards,

Panagiotis 


@PanagiotisCharalampous

dominhtri1995
11 Apr 2019, 11:04

Hi,

 

Please add the ability to open and close new chart window as well. We can now scan the whole market, identify opportunity across pairs , trade them but can't open a chart automatically ? 

 

THanks


@dominhtri1995

trader.calgo
23 Apr 2019, 17:26

Hi,

I am currently working with ML.NET and the main data type is float there. In this library there are custom solutions CpuMath and other dll written only for version x64. For the further development of cTrader-based neural networks, it is very important to add a compiler for x64 processors!


@trader.calgo

firemyst
06 May 2019, 12:05 ( Updated at: 21 Dec 2023, 09:21 )

Error in Intellisense and perhaps a bug?

HI SpotWare:

1) See the red-lines in screen capture. How come the property says "{ get; }", yet the description says "Get or sets"? It can't set if there's no "set" implementation.

2) See the compile error. I have this code under a Bot instance of "EURUSD", so how come SymbolName isn't valid in the current context if that's what we're supposed to use?

See screen capture:

3) If I replace "SymbolName" with "Symbol" on line 32, the compiler doesn't spit out an error message about using "Symbol.Code" on line 21 even though it's not there according to Intellisense. If it's 'deprecated', the compiler should at least say so:

Symbol.Code doesn't appear in intellisense, but compiles fine?

Thank you.


@firemyst

PanagiotisCharalampous
06 May 2019, 12:49

Hi FireMyst,

1) We will fix the description.

2) It seems you are using new features included in 3.5 but compiling with 3.3. To solve this issue, close Spotware cTrader 3.5, go to C:\Users\UserName\Documents\cAlgo\API, delete all files in the folder and restart cTrader 3.5.

3) Deprecated fileds are not shown in Intellisence. If you want to use v3.3 of the API, repeat the process described in point 2 but with a 3.3 instance of cTrader.

Best Regards,

Panagiotis


@PanagiotisCharalampous

firemyst
06 May 2019, 16:02

RE:

Panagiotis Charalampous said:

Hi FireMyst,

1) We will fix the description.

2) It seems you are using new features included in 3.5 but compiling with 3.3. To solve this issue, close Spotware cTrader 3.5, go to C:\Users\UserName\Documents\cAlgo\API, delete all files in the folder and restart cTrader 3.5.

3) Deprecated fileds are not shown in Intellisence. If you want to use v3.3 of the API, repeat the process described in point 2 but with a 3.3 instance of cTrader.

Best Regards,

Panagiotis

Awesome. That fixed issues 2 & 3. Thank you.

Whatever they're paying you, it's not enough. ;-)

 


@firemyst

VertoTrading
27 Jun 2019, 16:16

Hi There,

 

Is there any possibility of being able to have a cBot access the news events?

 

For example, place orders before orders and filter the news events based on their importance?


@VertoTrading

PanagiotisCharalampous
27 Jun 2019, 16:25

Hi VertoTrading,

No this is not possible via the API.

Best Regards,

Panagiotis


@PanagiotisCharalampous

event
29 Jun 2019, 08:48

Hi,

It is very inconvenient when the options window closes automatically.

It would be better if the options window closes only when you click the gear icon again.

Thanks


@event

alexandervkv
30 Jun 2019, 10:26

marketRangePips in Automate API 3.5

Hi Panagiotis,

is it possible to use marketRangePips in Automate API 3.5 ?

If I use Symbol it's OK:

ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "Stochastics Scalping", 10, 12, 2);

Buy if I use SymbolName:

ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000, "Stochastics Scalping", 10, 12, 2);

I get: Error CS1503: Argument 7: cannot convert from 'int' to 'string'

Best Regards,

Alexander


@alexandervkv

firemyst
30 Jun 2019, 15:15

RE: marketRangePips in Automate API 3.5

alexandervkv said:

Hi Panagiotis,

is it possible to use marketRangePips in Automate API 3.5 ?

If I use Symbol it's OK:

ExecuteMarketOrder(TradeType.Buy, Symbol, 10000, "Stochastics Scalping", 10, 12, 2);

Buy if I use SymbolName:

ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000, "Stochastics Scalping", 10, 12, 2);

I get: Error CS1503: Argument 7: cannot convert from 'int' to 'string'

Best Regards,

Alexander

To use MarketRangePips, there's a separate API call for that: "ExecuteMarketRangeOrder". See this page for more details:

https://ctrader.com/api/reference/robot/executemarketrangeorder

The reason you're getting the error with "ExecuteMarketOrder" is because the 7th parameter needs to be a "string", which is a comment on the order placed.

See this page for more details: https://ctrader.com/api/reference/robot/executemarketorder

Hope that helps :-)


@firemyst

... Deleted by UFO ...

... Deleted by UFO ...