cTrader · C# cBots
cTrader cBot developer for C# trading bots
KMG Capital builds, repairs, and validates cTrader cBots: strategy rules in C#, risk sizing, session and prop-firm limits, and the evidence that the bot behaves in cTrader the way it did in research.
Work is led directly by founder Jad Kabbaj. Common starting points: a TradingView strategy to port, a cBot that trades differently live than in its backtest, or a strategy that needs optimization without overfitting.
cBot work
From trading rules to a cBot you can trust with an account.
The work covers the C# code and the conditions around it: the broker’s symbol contract, sessions, swap, and the account’s risk limits.
cBots from rules or from TradingView
C# cBots written from your rules, or ported from a Pine Script strategy with its signal logic, inputs, and defaults kept intact.
Risk sizing and account limits
Position size from a fixed dollar or percent risk, daily and total loss limits, and prop-firm rules such as a 17:00 New York trading-day cutoff.
Optimization without overfitting
Fast bar-based searches to find candidates, bid/ask tick replays of the shortlist, train, development, and holdout periods in time order, and checks that neighboring settings still hold up.
Fixes for existing cBots
Bots that trade differently live, hold positions through weekends, or size volumes wrongly, including code taken over from another developer. A written trading system audit is available when the cause is unclear.
One detail that catches many first cBots: entry methods take stop loss and take profit as distances in pips, so the volume comes from the dollar risk and the stop distance.
// cTrader entry methods take stop loss and take profit in pips, not prices.
double volume = Symbol.NormalizeVolumeInUnits(
riskDollars / (stopPips * Symbol.PipValue), RoundingMode.Down);
ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, "Entry", stopPips, targetPips);Case study · native parity
What a bar-based backtest got wrong on a USTEC cBot.
An intraday cBot on USTEC (Nasdaq 100 CFD) from KMG’s own research. IC Markets data from January 2023 to June 2026, $20,000 starting balance, about 1,775 trades. Same code and settings, five ways of testing it.
| Testing method | Net profit |
|---|---|
| M5 bar replay, swap charged at 23:00 UTC | ≈ +$4,519 |
| M5 bar replay, swap moved to the ≈ 21:00 UTC rollover | ≈ +$3,079 |
| Bid/ask tick replay, no added slippage* | ≈ +$2,756 |
| Native cTrader backtest, the reference* | ≈ +$2,354 |
| Tick replay with 2 pips added per fill (stress test) | ≈ +$1,501 |
* Tick replay and native cTrader rows share the exact end date, 26 June 2026, the last day of available tick data.
- Swap time was the biggest error. Charging overnight swap at 23:00 UTC instead of the broker’s rollover at about 21:00 UTC overstated profit by about $1,440. Example: in winter, a 16:50 New York close is 21:50 UTC, after the rollover, so a bot that closes every day still pays swap.
- Entries matched exactly. All 1,771 entries in the common period matched native cTrader on bar minute and direction, and on price with no added slippage.
- Session closes explained the rest. 1,725 of 1,771 exits matched within 60 seconds. The other 46 accounted for about $426 of overstatement, almost all from forced closes around shortened sessions.
- OnBarClosed can miss the close. It only fires when the next bar opens. Before shortened sessions such as 24 November 2023 and 4 July 2025, a bar-close flatten rule never ran and positions stayed open until Sunday.
- Dates must match exactly. A native run ending four days later added four trades worth about $118, enough to blur the comparison.
The native result was roughly half the first bar-based estimate. With a profit factor near 1.04, a small error in gross profit becomes a large share of net profit. The strategy was later rejected after a frozen out-of-sample test; the parity work had already shown its edge was much thinner than the first model suggested.
How it works
Search fast, then prove it on cTrader.
- 01
Confirm the symbol contract
Pip and tick size, volume limits, commission, leverage, swap values, rollover time, and session calendar, taken from the broker before any test.
- 02
Search on bars
Bar-based optimization finds candidate settings quickly, with train, development, and holdout periods kept in time order.
- 03
Replay the shortlist on ticks
Real bid/ask ticks with the same build and settings measure stops, targets, and equity drawdown on the true price path.
- 04
Confirm in native cTrader
The same cBot runs in a native cTrader backtest with identical dates. Trades are matched one by one, and every exit more than 60 seconds apart is explained.
Common questions
Before you start
Can you convert a TradingView strategy into a cTrader cBot?
Yes. The cBot is built from the Pine Script source, keeping its signal rules, inputs, and defaults. If you prefer to keep the strategy on TradingView, its alerts can be bridged to cTrader instead.
Can you fix a cBot someone else wrote?
Yes. Common issues include volumes that don’t match the risk setting, positions held through weekends or holidays, and live trades that differ from the backtest. If the cause is unclear, start with a Trading System Diagnostic.
Can a cBot follow prop-firm challenge rules?
Yes. Daily and total loss limits, trading-day cutoffs, and profit targets can be built into the cBot, and optimization can rank settings by valid challenge passes instead of raw profit.
Do you guarantee results?
No. KMG Capital provides software, research, and technical consulting. A validated backtest shows how rules behaved on past data; it is not a forecast or investment advice.
cTrader cBot development
Bring the rules, the code, or the backtest that doesn’t add up.
Share the strategy, the symbol, and where the project stands. Jad will reply directly with a useful next step.