What's New in cTrader Automate API 3.5

What's New in cTrader Automate API 3.5

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

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";

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: https://ctrader.com/forum/suggestions