The Supertrend indicator is one of the most popular tools for identifying market direction and potential trend changes. It is widely used by traders because it provides a simple visual signal: bullish conditions when the price moves above the Supertrend line, and bearish conditions when it moves below it.
In this tutorial, we show how Xen AI can be used to build a complete Supertrend trading bot for cTrader without having to write code. Instead of starting from a blank editor, traders can describe the strategy in plain English and let Xen AI generate the cBot structure, trading rules and configurable parameters.
What the Supertrend cBot Does
The strategy follows the direction of the Supertrend indicator. When the market changes from bearish to bullish, the cBot looks for a buy opportunity. When the market changes from bullish to bearish, the cBot looks for a sell opportunity.
The robot is designed to keep the logic simple and clear, making it ideal for traders who want to learn how to build automated trading strategies in cTrader.
Core Strategy Rules
- Open a buy position when the Supertrend changes from bearish to bullish.
- Open a sell position when the Supertrend changes from bullish to bearish.
- Only allow one open position per symbol.
- Close the current position when the Supertrend reverses.
- Use ATR-based stop loss and risk-reward-based take-profit levels.
Why This Strategy Works Well as a cBot Example
The Supertrend strategy is a strong example for AI-assisted cBot development because it includes real trading logic without becoming too complex. It demonstrates entries, exits, stop loss calculation, take profit calculation and configurable inputs. This makes it a practical starting point for traders who want to understand how Xen AI can help turn a trading idea into working cTrader Automate code.
Using Xen AI to Build the cBot
Xen AI allows traders to describe the trading robot they want to build using natural language. The AI then generates the cBot code for cTrader Automate, including the core trading logic and user-configurable parameters.
For this Supertrend example, the user prompt can include the Supertrend period, multiplier, ATR stop-loss multiplier, risk-reward ratio, and fixed trading volume. Xen AI then builds the cBot around these requirements.
Example Xen AI Prompt
Build a professional cTrader cBot using the official cTrader Automate API.
Create a trend following strategy based on the Supertrend indicator.
Trading Rules
- Open a Buy position when the Supertrend changes from bearish to bullish.
- Open a Sell position when the Supertrend changes from bullish to bearish.
- Only allow one open position per symbol.
- Close the current position immediately when the Supertrend reverses.
Risk Management
- Calculate the Stop Loss using the Average True Range (ATR) multiplied by a configurable multiplier.
- Calculate the Take Profit using a configurable Risk Reward ratio.
User Inputs
- Supertrend ATR Period
- Supertrend Multiplier
- ATR Stop Loss Multiplier
- Risk Reward Ratio
- Fixed Volume (Lots)
Backtesting and Optimisation
Once the cBot has been generated, it can be tested inside cTrader using historical market data. Traders can then optimise the Supertrend period, multiplier, ATR stop-loss multiplier, and risk-reward ratio to explore different settings.
Backtesting does not guarantee future performance, but it helps traders understand how a strategy behaves across different market conditions before using it on a live account.
Possible Future Enhancements
- Add an EMA trend filter.
- Add ATR trailing stops.
- Add break-even logic.
- Add session-based trading filters.
- Add spread protection.
- Add percentage risk position sizing.
Final Thoughts
The Supertrend cBot is an ideal example of how Xen AI can help traders build automated trading strategies for cTrader faster. It keeps the strategy simple enough to understand while still showing useful professional features such as trend detection, ATR-based stop loss and configurable trade settings.
For traders who want to build cBots but do not want to start with manual C# coding, Xen AI provides a faster workflow from idea to working trading robot.

