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.
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). Use Bars to address this deprecation, then check the targeted API version. Removing one obsolete member does not guarantee compatibility with future updates.
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).
// 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;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.
// 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 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.
// Legacy cAlgo:
// MarketSeries dailySeries = MarketData.GetSeries(Symbol, TimeFrame.Daily);
// Modern cTrader:
Bars dailyBars = MarketData.GetBars(TimeFrame.Daily, SymbolName);
double dailyClose = dailyBars.ClosePrices.Last(1);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.
Update MarketSeries property access first, then compare signal timestamps and values before changing trade logic. Inspect remaining diagnostics separately.
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.
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.
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 produces a C# draft for source review and native testing.
Open the cTrader Coding Agent