cTrader cBots: A Practical Guide to Algorithmic Trading on cTrader
cTrader cBots are automated trading programs written in C# (and, in recent versions, Python) that run inside the cTrader platform, the alternative to MetaTrader built by Spotware and offered by a number of brokers regulated in the UK and Australia. A cBot reacts to events such as a new tick or a new bar, places and manages orders through a clean, well-documented API, and can be backtested and optimised in the same application. For programmers, the appeal is that you write in a mainstream language rather than a platform-specific one; the trade-off is a smaller ecosystem than MetaTrader's.
Key takeaways
- cBots are built in the platform's Algo section (formerly cTrader Automate, and before that cAlgo) using C# on modern .NET.
- A cBot is a class inheriting from Robot, with OnStart, OnTick, OnBar and OnStop methods.
- Order sizes in cTrader are expressed in units, not lots, which is the most common source of sizing bugs for MetaTrader converts.
- The built-in backtester supports tick data from the broker's server and parameter optimisation.
- In the UK and Australia, retail leverage is capped at 30:1 on major pairs with negative balance protection, and those limits apply to cBots too.
What cTrader and cBots are
cTrader is a multi-asset trading platform developed by Spotware and licensed to brokers. It is known for depth-of-market display, a clear separation of positions and orders, and a design aimed at ECN-style pricing. Its automation component lets you build two kinds of program in the same environment: indicators, which draw on charts, and cBots, which trade. Over the years the component has been called cAlgo, then cTrader Automate, and is now presented as cTrader Algo; you will see all three names in older tutorials and forum posts.
The language is C#, running on modern .NET in current versions, which means you can use standard .NET libraries, structure larger projects properly, and edit code either in the built-in editor or in Visual Studio. Recent cTrader releases have also added support for writing algorithms in Python; availability depends on your cTrader version and broker build, so check what your installation offers.
cTrader is available as a Windows desktop application, a Mac application and a web version. cBots are developed and backtested in the desktop apps. Recent versions also let you run cBots on Spotware's cloud infrastructure so they keep working while your device is off; features and limits of the cloud option vary by version, so read the current documentation.
The anatomy of a cBot
Every cBot is a C# class that inherits from Robot and is marked with a [Robot] attribute. The attribute declares the access rights the cBot needs. AccessRights.None is the safe default; file system or internet access must be requested explicitly, which gives users a clear signal of what a downloaded cBot can do.
The main lifecycle methods are:
- OnStart() runs once when the cBot starts. Create indicators, validate parameters and set up event handlers here.
- OnTick() runs on every price update for the chart's symbol. Use it for logic that must react within a bar, such as custom trailing stops.
- OnBar() runs when a new bar opens. Most swing and trend strategies belong here, which also makes them much faster to backtest.
- OnStop() runs when the cBot is stopped, for clean-up and logging.
Inputs a user can change are declared as properties with a [Parameter] attribute, for example [Parameter("Fast MA Period", DefaultValue = 20, MinValue = 2)]. These appear in the cBot's settings panel and are the values the optimiser varies.
Placing a trade is a single readable call:
ExecuteMarketOrder(TradeType.Buy, SymbolName, volumeInUnits, "MyBot", stopLossPips, takeProfitPips);
Open positions are queried through Positions, for example Positions.FindAll("MyBot", SymbolName), and indicators are built from the Indicators collection, such as Indicators.SimpleMovingAverage(Bars.ClosePrices, 50). Event handlers like Positions.Closed let a cBot react immediately when a stop-loss or take-profit fills, rather than discovering it later.
Sizing in units: the conversion MetaTrader users get wrong
MetaTrader works in lots. cTrader's API works in units of the base currency: 100,000 units is one standard lot, 1,000 units a micro lot. The symbol object provides helpers such as Symbol.QuantityToVolumeInUnits() to convert lots to units and Symbol.NormalizeVolumeInUnits() to round to the broker's allowed step. Symbol properties also give you pip size and pip value in the account currency, so you do not need to hard-code them.
Worked example: Australian account trading EUR/USD
Suppose an Australian trader has an A$20,000 account and codes a cBot to risk 1% per trade, A$200. The strategy's stop is 30 pips on EUR/USD. One standard lot of EUR/USD is worth US$10 per pip. With AUD/USD at 0.6500, that converts to about A$15.38 per pip per standard lot.
Position size in lots = 200 ÷ (30 × 15.38) = 0.433 lots, or about 43,300 units. Normalised down to a 1,000-unit step, that is 43,000 units, risking about A$198.
Margin at the ASIC retail cap of 30:1: 43,000 × 1.0850 (EUR/USD) = US$46,655 notional, divided by 30 = US$1,555, or roughly A$2,393. Comfortably inside the account, but note that running several cBots at once adds margin quickly.
The common bug is passing 0.43 as the volume, which cTrader reads as 0.43 units and rejects, or passing 43 thinking in micro lots. Always convert explicitly and log the final volume before sending.
cBots compared with MetaTrader EAs
| Feature | cTrader cBots | MetaTrader 5 EAs |
|---|---|---|
| Language | C# on .NET (Python in recent versions) | MQL5 |
| Volume unit | Units of base currency | Lots |
| Editor | Built-in or Visual Studio | MetaEditor |
| Permissions model | Declared access rights per cBot | Terminal-wide and per-EA settings for DLLs and web requests |
| Backtesting data | Broker server tick data or bar data | Broker real ticks, generated ticks or bars |
| Optimisation | Built in, including genetic algorithm | Built in, multi-core and cloud agents |
| Ecosystem | Smaller library of community and commercial cBots | Very large marketplace and community |
| Broker availability | Fewer brokers | Very widely offered |
If you are deciding between platforms more broadly, our comparison of MQL4 and MQL5 covers the MetaTrader side, and our guide to Python forex trading bot APIs covers building outside any platform.
Backtesting and optimisation in cTrader
Open a cBot in the Algo section and switch to the backtesting tab. Choose the date range, the starting capital and the data source. The most realistic option uses tick data from the broker's server; bar-based options run faster and are fine for rough checks of strategies that only act at bar open. Set commission to match the account type you intend to trade, since raw-spread accounts charge per trade, and check whether spread is taken from the data or fixed.
The results panel shows net profit, maximum balance and equity drawdown, profit factor, Sharpe and Sortino ratios, the trade list and an equity chart. Read it the same way you would any backtest: hundreds of trades, drawdown you could live through, and an equity curve that does not depend on one lucky period.
The optimiser varies the parameters you mark and ranks results by a chosen criterion. Use it to find stable regions where many nearby settings work, not the single best combination. Hold back a recent period, then test the chosen settings on it. The danger of optimisation is identical on every platform and is explained in our article on curve fitting in EAs.
Most important risk point: a cBot executes exactly what its code says, including mistakes. A sizing error in units, an event handler that reopens trades after every stop, or an optimised strategy that only fitted the past can lose money quickly, and leverage magnifies those losses. Most retail CFD accounts lose money. Run every new cBot on a demo account, add a hard cap on volume and a daily loss stop in the code, and monitor it after going live.
UK and Australia: regulation and broker choice
cBots trade on whatever account they run on, so the regulatory protections are those of the broker entity you sign with.
United Kingdom
FCA-authorised brokers apply the retail leverage limit of 30:1 on major currency pairs and 20:1 on non-major pairs, gold and major indices, a margin close-out rule at 50% of required margin, negative balance protection and mandatory risk warnings. Client money is held in segregated accounts, and eligible claims may be covered by the Financial Services Compensation Scheme up to its limit if a firm fails. Several brokers offering cTrader hold FCA authorisation for their UK entity; check the FCA register for the exact legal entity on your account agreement. Our list of FCA-regulated forex brokers is a starting point.
Australia
ASIC's product intervention order applies the same 30:1 cap on major currency pairs to retail clients, alongside a 50% margin close-out rule and negative balance protection. Australia has historically been a strong market for cTrader, and a number of ASIC-licensed brokers offer it. As with the UK, some of these brands also run offshore entities where Australian protections do not apply, so confirm which entity you are onboarded with. Our guide to ASIC-regulated brokers explains how to check. If you hold professional client status, higher leverage may be available, but you give up some retail protections.
Brokers whose reviews on our site cover cTrader availability include Pepperstone and IC Markets. Account types, platforms and entities change, so confirm cTrader availability and conditions on each broker's official site at the time you open an account.
Running cBots reliably
Like any automated system, a cBot is only as reliable as the environment it runs in. Running cTrader on a home PC means sleep mode, Windows updates or a dropped connection stop the bot. The options are a Windows VPS, ideally close to your broker's servers, or Spotware's cloud execution where your version supports it. Whichever you choose:
- Log every decision with
Print()so you can reconstruct what happened. - Handle failed trade results: check
TradeResult.IsSuccessfuland the error code rather than assuming orders were filled. - Make the cBot restart-safe. When it starts, it should find its existing positions by label and resume managing them, not open duplicates.
- Decide what happens over weekends and around major news, when spreads widen and gaps are common.
Frequently asked questions
What programming language do cTrader cBots use?
cBots are written in C# running on .NET, using cTrader's Algo API. Recent cTrader versions have also added the option of writing algorithms in Python. You can code in the built-in editor or in Visual Studio. Because C# is a general-purpose language, you can use standard .NET libraries and good software practices, which many programmers prefer to a platform-specific language.
Is cTrader better than MetaTrader for algorithmic trading?
Neither is universally better. cTrader offers a mainstream language, a clean API and a clear permissions model. MetaTrader offers a much larger ecosystem, more brokers and a powerful multi-core tester. Programmers comfortable in C# often prefer cTrader, while traders who want the broadest broker choice or access to many existing EAs usually stay with MetaTrader.
Can I convert an MT4 or MT5 EA into a cBot?
Not automatically. The logic must be rewritten in C# against cTrader's API, paying particular attention to volume in units rather than lots, how positions are identified and how indicators are accessed. After rewriting, backtest both versions over the same period and compare trade lists before trusting the cBot on a live account.
Do cBots run when my computer is off?
Not if they run in the desktop application, which must stay open and connected. To keep a cBot running continuously, use a VPS or, in recent cTrader versions, Spotware's cloud execution option. Check the cloud feature's current limits on resources and permissions in the official documentation, as some cBots that need file or internet access may not be supported there.
What leverage can a cBot use with a UK or Australian broker?
The same as any retail client of that broker entity: up to 30:1 on major currency pairs under FCA and ASIC rules, with lower caps on minors and other assets, plus negative balance protection. Professional clients may access more, with fewer protections. If you trade through an offshore entity of the same brand, different and usually weaker rules apply.
Are cBots allowed at prop firms?
Some prop firms offer cTrader and allow automated trading, others restrict it or ban certain behaviours such as high-frequency trading, latency arbitrage or copying the same strategy across accounts. Rules differ by firm and change over time, so read the firm's terms on algorithmic trading before running a cBot on an evaluation or funded account.
This article is general information, not personal financial advice. Figures such as spreads, fees, leverage and rules change; confirm them with the provider and check the provider is authorised for your country of residence.