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 is deprecated; the cAlgo.API.Internals namespace is still used by current API types such as Algo and Symbol. Replace obsolete members rather than deleting the namespace indiscriminately.
  • 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). Use Bars to address this deprecation, then check the targeted API version. Removing one obsolete member does not guarantee compatibility with future 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

Map each MarketSeries property to its Bars equivalent. The two blocks below are before-and-after alternatives, not one method: choose one block rather than declaring the same local names twice. Ensure sufficient bar history before reading Last(1).

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

Last(0) and LastValue select the last bar present in the collection. In OnBar this is the newly opened bar and Last(1) is completed. In OnBarClosed the live bar is omitted, so Last(0) is the just-closed bar. In historical indicator calculations, use the supplied index rather than the end of the collection.

The following methods belong in separate cBot and indicator classes. Before the cBot reads Last(1), require at least two bars. The indicator needs a declared Output series. These fragments illustrate indexing only; they omit the surrounding class, attributes, and guards. Reading a completed bar addresses that timing choice, not every possible source of 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 an independent Bars collection. The snippet below reads the previous daily bar relative to the current loaded daily series and requires at least two daily bars. It is not a historical cross-timeframe alignment algorithm. To evaluate a historical signal, map its timestamp through dailyBars.OpenTimes.GetIndexByTime, validate the index, and step back if the mapped daily bar was unfinished at that signal time.

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

A migration may involve parameter attributes, nested indicator calls, and obsolete members as well as the price collection name. Review each dependency against the target API.

Pineify cTrader AI Coding Agent accepts your legacy C# snippet and rewrites it to match modern cTrader.Automate conventions. Compiler diagnostics can help identify obsolete members. Inspect the final source and reported diagnostics before native testing; a passing check alone does not establish that every migration requirement was met.

  • Automated conversion of MarketSeries calls to Bars collections
  • Verification against official cTrader.Automate 1.0.19 compiler diagnostics
  • Compare original parameters, stops, and trade rules with the revised source
  • Single-file C# draft for native build and behavior checks

Practical checks

Replace property names before touching trade logic

Update MarketSeries property access first, then compare signal timestamps and values before changing trade logic. Inspect remaining diagnostics separately.

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

Check whether the older script used Last(0) or Last(1) and which callback reads it. OnBar and OnBarClosed have different views of the last bar.

Verify compiler output under cTrader.Automate 1.0.19

Run the supported compiler check and review reported diagnostics, then build in the target terminal. Confirm required API replacements in the source instead of treating compilation as a behavior test.

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 produces a C# draft for source review and native testing.

Open the cTrader Coding Agent