What's New in cTrader Automate API 3.5

05 Mar 2019, 11:20What's New in cTrader Automate API 3.5#1
cTrader Teamposts: 3396since: 23 Sep 2013

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


TRADERS FIRST™ Vote for your favorite features: http://vote.spotware.com/
05 Mar 2019, 13:32#2
Ahmad Noman Muslehposts: 96since: 15 Oct 2015

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.


http://algodeveloper.com/
05 Mar 2019, 16:58#3
trader.calgoposts: 21since: 19 Feb 2018


it's great! Thanks you

06 Mar 2019, 02:44#4
.icsposts: 62since: 10 Mar 2015

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


cTrader community chat on Discord: https://discord.gg/uzu7PdH --- If your strategy is profitable, i provide coding services for your algo free of charge under Non Disclosure Agreement terms.
06 Mar 2019, 10:19#5
Panagiotis Charalampousposts: 3519since: 13 Jan 2017

Hi .ics,

No this is not available yet.

Best Regards,

Panagiotis


Head of Community Management at cTrader
06 Mar 2019, 10:58#6
darcomeposts: 19since: 23 Jan 2019

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

06 Mar 2019, 11:04#7
Panagiotis Charalampousposts: 3519since: 13 Jan 2017

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


Head of Community Management at cTrader
06 Mar 2019, 11:13#8
darcomeposts: 19since: 23 Jan 2019

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 :(

07 Mar 2019, 07:01#9
Xavier Rposts: 95since: 12 May 2015

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

 


¨You are not what you have done, you are what you have overcome.¨ - Anonymous
07 Mar 2019, 13:10IsOverlay not work as previous version did.#10
abc posts: 18since: 06 Feb 2017

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.