cTrader API migration guide

Migrate cAlgo MarketSeries to Bars in cTrader C#

Older cAlgo tutorials and scripts rely on MarketSeries to read historical price and volume data. Modern cTrader.Automate replaces MarketSeries with Bars. This guide provides the property mappings, syntax updates, and compiler checks needed to update your C# cBots and indicators.

Direct answer

In modern cTrader C# development, cAlgo.API.Internals.MarketSeries is obsolete and triggers compiler warnings or errors under current cTrader.Automate references. Replace this.MarketSeries with this.Bars. Map legacy properties such as Close, Open, High, Low, OpenTime, and TickVolume to Bars.ClosePrices, Bars.OpenPrices, Bars.HighPrices, Bars.LowPrices, Bars.OpenTimes, and Bars.TickVolumes.

What to know first

  • MarketSeries and the cAlgo.API.Internals namespace are deprecated. Modern cTrader algorithms use Bars.
  • Both Robot and Indicator base classes expose this.Bars directly without requiring special imports.
  • Singular price series such as Close and Open are replaced by plural names: ClosePrices, OpenPrices, HighPrices, and LowPrices.
  • Multi-timeframe retrieval changes from MarketData.GetSeries to MarketData.GetBars.
  • Pineify cTrader AI Coding Agent generates and checks C# code against cTrader.Automate 1.0.19 to detect and resolve obsolete API members.

cAlgo MarketSeries vs modern cTrader Bars

Feature / PropertyLegacy cAlgo (MarketSeries)Modern cTrader (Bars)
Class namespacecAlgo.API.Internals.MarketSeriescAlgo.API.Bars
Base class propertythis.MarketSeries (obsolete)this.Bars
Price series namesClose, Open, High, Low (singular)ClosePrices, OpenPrices, HighPrices, LowPrices (plural)
Tick volume propertyMarketSeries.TickVolumeBars.TickVolumes
Bar timestampsMarketSeries.OpenTimeBars.OpenTimes
Higher timeframe helperMarketData.GetSeries(symbol, timeframe)MarketData.GetBars(timeframe, symbolName)
Compiler statusCS0618 obsolete warning or compilation errorStandard supported interface in cTrader.Automate

Why MarketSeries is obsolete in modern cTrader

cAlgo originally exposed price and volume data through the MarketSeries interface under cAlgo.API.Internals. As cTrader evolved into cTrader Automate and introduced richer data access for ticks, bars, and multi-symbol charts, the API team redesigned data collections around the Bars interface.

Modern versions of cTrader (including cTrader.Automate 1.0.19) mark MarketSeries as obsolete (CS0618). Code targeting newer runtime packages must use Bars to avoid deprecation warnings and ensure compatibility with future platform updates.

  • cAlgo.API.Internals.MarketSeries is marked obsolete in modern cTrader releases
  • The Bars property is a first-class member on both Robot and Indicator classes
  • Bars provides cleaner separation between price collections, timestamps, and tick volumes

Property mapping reference: MarketSeries to Bars

When refactoring legacy cAlgo code, replace property calls on MarketSeries with their direct equivalents on Bars. Most changes involve switching to plural property names.

C# Property Mapping: MarketSeries vs Bars
// Legacy cAlgo (Obsolete)
double closePrice = MarketSeries.Close.LastValue;
double previousHigh = MarketSeries.High.Last(1);
DateTime openTime = MarketSeries.OpenTime.Last(1);
double volume = MarketSeries.TickVolume.LastValue;

// Modern cTrader (cTrader.Automate 1.0.19)
double closePrice = Bars.ClosePrices.LastValue;
double previousHigh = Bars.HighPrices.Last(1);
DateTime openTime = Bars.OpenTimes.Last(1);
double volume = Bars.TickVolumes.LastValue;
  • MarketSeries.Close becomes Bars.ClosePrices
  • MarketSeries.Open becomes Bars.OpenPrices
  • MarketSeries.High becomes Bars.HighPrices
  • MarketSeries.Low becomes Bars.LowPrices
  • MarketSeries.OpenTime becomes Bars.OpenTimes
  • MarketSeries.TickVolume becomes Bars.TickVolumes
  • MarketSeries.Median becomes Bars.MedianPrices
  • MarketSeries.Typical becomes Bars.TypicalPrices
  • MarketSeries.Weighted becomes Bars.WeightedPrices

Index conventions and reading historical values

Both MarketSeries and Bars share the same indexing logic for Last() and indexer syntax. Last(0) or LastValue refers to the currently forming bar, while Last(1) refers to the most recently completed bar.

In indicator Calculate(int index) methods, read values using index notation: Bars.ClosePrices[index]. When evaluating signals in a cBot OnBar() handler, prefer reading completed bar data via Last(1) to avoid intrabar signal repainting.

C# Accessing bar values in cBots and Indicators
// Inside a cBot OnBar method (evaluating closed bar):
protected override void OnBar()
{
    double closedBarClose = Bars.ClosePrices.Last(1);
    double closedBarOpen = Bars.OpenPrices.Last(1);

    if (closedBarClose > closedBarOpen)
    {
        // Bullish candle condition
    }
}

// Inside a Custom Indicator Calculate method:
public override void Calculate(int index)
{
    double currentClose = Bars.ClosePrices[index];
    Output[index] = currentClose;
}

Multi-timeframe and multi-symbol data migration

Older cAlgo algorithms loaded external timeframes through MarketData.GetSeries(symbol, timeframe). In modern cTrader Algo API, this method is replaced by MarketData.GetBars.

MarketData.GetBars returns a Bars object for the requested timeframe and symbol. You can access ClosePrices, OpenTimes, and other series on the returned instance in the same manner as the primary chart Bars.

C# Loading higher timeframe bars
// Legacy cAlgo:
// MarketSeries dailySeries = MarketData.GetSeries(Symbol, TimeFrame.Daily);

// Modern cTrader:
Bars dailyBars = MarketData.GetBars(TimeFrame.Daily, SymbolName);
double dailyClose = dailyBars.ClosePrices.Last(1);

Automating migrations with Pineify cTrader Coding Agent

Migrating multiple legacy cAlgo robots or indicators by hand can be slow, especially when outdated parameter attributes, nested indicator calls, and deprecated namespaces are mixed together.

Pineify cTrader AI Coding Agent accepts your legacy C# snippet and rewrites it to match modern cTrader.Automate conventions. The service runs a compiler diagnostic check to confirm that obsolete MarketSeries references are eliminated before you test the code in cTrader.

  • Automated conversion of MarketSeries calls to Bars collections
  • Verification against official cTrader.Automate 1.0.19 compiler diagnostics
  • Preservation of original strategy parameters, stop loss, and trade rules
  • Single-file C# output ready to compile in cTrader Windows or Mac

Practical checks I use

Replace property names before touching trade logic

When refactoring legacy cAlgo robots, I replace MarketSeries with Bars and update price series names first. That clears obsolete warnings so I can focus on testing.

Check Last(0) vs Last(1) in signal evaluation

I always check whether an older script used Last(0) or Last(1). In OnBar, Last(1) evaluates the completed bar, while Last(0) looks at the newly opened bar.

Verify compiler output under cTrader.Automate 1.0.19

I run compiler checks against cTrader.Automate to confirm zero obsolete warnings before loading a modernized cBot into cTrader.

Primary sources

Pineify is an information tool, not investment advice. Modernizing C# code and compiler checks do not guarantee strategy profitability or execution safety. Always test updated code on a demo account before risking live funds.

Frequently asked questions

Modernize your cAlgo C# code with AI compiler checks

Paste legacy cAlgo robots or indicators into Pineify. The agent updates deprecated MarketSeries calls to modern Bars, checks compiler diagnostics against cTrader.Automate 1.0.19, and outputs clean C#.

Open the cTrader Coding Agent