Advertisement IC Markets

cTrader cBots: Automation in C#

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
FXS Prop Desk
Posts: 1689
Joined: Wed Oct 07, 2026 9:52 am

cTrader cBots: Automation in C#

Post by FXS Prop Desk »

cTrader uses C# for automated strategies (cBots) and custom indicators. For developers familiar with modern languages, it is an alternative to MQL.

Advantages:
  • Full C# language features and .NET libraries.
  • Clear API for orders, positions and market data.
  • Backtesting with tick data.
  • Cloud execution options.
Considerations:
  • Fewer ready-made tools than MT4/MT5.
  • Not all brokers or prop firms offer cTrader.
  • Migration from MQL requires rewriting.
A simple cBot structure: OnStart for setup, OnBar or OnTick for logic, OnStop for cleanup.

For traders who already use C# elsewhere, being able to use familiar tools such as unit testing frameworks and version control is a real advantage when strategies become more complex.

Do you use cBots, and how do they compare to MQL for you?
FXS Official Team | The Idea Lab & Strategy
Recommended broker for automated trading & scalping IC Markets
Shadow Trader
Posts: 5594
Joined: Wed Sep 09, 2026 5:19 pm

Re: cTrader cBots: Automation in C#

Post by Shadow Trader »

I rewrote one mean reversion scalp from MQL5 into a cBot last quarter mainly to keep unit tests around the entry filter. The C# version caught a timezone bug on Sunday bars that the MQL live run had been silently mishandling for weeks.

Tick backtests on cTrader lined up closer to my live fills than the M1 bar tests I used on MT5. That alone justified the rewrite for a strategy that lives inside a 6 to 8 pip target.
img_13718_r1.png
img_13718_r1.png (150.41 KiB) Viewed 104 times
The illustration compares fill slip on the same 120 trade block under both stacks. Prop access is still the blocker: two of the three firms I use simply do not offer cTrader, so the bot stays on a personal account for now.

Would you move a live EA if the firm forced MT5 only? I keep analysis ideas portable and execute where the account lives.
Shadow Trader
Posts: 5594
Joined: Wed Sep 09, 2026 5:19 pm

Re: cTrader cBots: Automation in C#

Post by Shadow Trader »

The bug I see most in cBots ported by people coming from MQL is reading the wrong bar in OnBar. That event fires when a new bar opens, so the bar that just closed is Bars.Last(1), while Last(0) is the fresh bar with a single tick in it.

My first port had exactly that mistake. Every signal was computed on an almost empty candle, and the backtest still looked plausible, which is the dangerous part.

Access rights are the other surprise. A cBot that writes a trade log to disk needs full access declared in its robot attribute, and the user has to approve that, so a bot that ran fine on my laptop could not keep its log once I moved it to the cloud setup.

I ended up printing the log lines to the platform output instead and copying them out once a day. It is clumsy, but it kept the bot on the restricted setting, which I prefer for anything running unattended.

Have you found a clean way to keep persistent state in a cloud cBot? I would like the daily loss count to survive a restart.
Shadow Trader
Posts: 5594
Joined: Wed Sep 09, 2026 5:19 pm

Re: cTrader cBots: Automation in C#

Post by Shadow Trader »

Some scalpers outgrow retail platforms and move to alternatives offering lower latency and more control. cTrader is a platform popular with ECN brokers, offering depth of market, level-two pricing, and a modern automation interface through cAlgo.

FIX API access goes further, allowing direct connection to a broker's trading engine using the Financial Information eXchange protocol. This removes the overhead of retail platform processing and gives fine-grained control over order types and timing. Brokers that offer it typically require a minimum deposit or trading volume.

The trade-offs include more development effort, since a FIX connection requires custom software to manage sessions, messages, and recovery. Costs may include server hosting and market data fees. For strategies where milliseconds matter, the investment can pay off. For most retail scalpers, a well-configured platform on a nearby VPS achieves most of the available benefit. Evaluating whether the gain justifies the complexity requires measuring the actual latency difference and its effect on results.
Post Reply