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.
cTrader API migration guide
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.
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.
| Feature / Property | Legacy cAlgo (MarketSeries) | Modern cTrader (Bars) |
|---|---|---|
| Class namespace | cAlgo.API.Internals.MarketSeries | cAlgo.API.Bars |
| Base class property | this.MarketSeries (obsolete) | this.Bars |
| Price series names | Close, Open, High, Low (singular) | ClosePrices, OpenPrices, HighPrices, LowPrices (plural) |
| Tick volume property | MarketSeries.TickVolume | Bars.TickVolumes |
| Bar timestamps | MarketSeries.OpenTime | Bars.OpenTimes |
| Higher timeframe helper | MarketData.GetSeries(symbol, timeframe) | MarketData.GetBars(timeframe, symbolName) |
| Compiler status | CS0618 obsolete warning or compilation error | Standard supported interface in cTrader.Automate |
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.
When refactoring legacy cAlgo code, replace property calls on MarketSeries with their direct equivalents on Bars. Most changes involve switching to plural property names.
// 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;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.
// 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;
}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.
// Legacy cAlgo:
// MarketSeries dailySeries = MarketData.GetSeries(Symbol, TimeFrame.Daily);
// Modern cTrader:
Bars dailyBars = MarketData.GetBars(TimeFrame.Daily, SymbolName);
double dailyClose = dailyBars.ClosePrices.Last(1);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.
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.
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.
I run compiler checks against cTrader.Automate to confirm zero obsolete warnings before loading a modernized cBot into cTrader.
Modernize and check C# cBots and indicators with compiler diagnostics.
Learn how to call ExecuteMarketOrder in cBots and convert volume in units.
Understand the architecture of cTrader Algo API, Automate, and namespaces.
Build an automated trading robot with modern C# standards.
Generate custom indicators with Bars data access and chart outputs.
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.
Generate single-file cTrader C# cBots and custom indicators, then review compiler diagnostics in the same coding workflow.
Distinguish cTrader Algo API, Automate, cAlgo, Open API, and FIX API before writing C# cBots or indicators.
Turn explicit entry, exit, position, and risk rules into editable single-file cTrader C# cBot source.
Create editable cTrader C# custom indicator source for formulas, output series, and chart objects.
Learn how to call ExecuteMarketOrder in cTrader cBots, bridge indicator signals, convert volume units, and handle trade results.
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