Custom Tools and AI
Create a cTrader indicator with AI
Use a small visual tool for a first AI-assisted project: an indicator that marks completed-bar moving-average crossovers. The aim is to verify a precise calculation, not to produce trading advice or an automatic strategy.
Define the indicator before generating it
Use a 20-period and a 50-period simple moving average of closing prices. An upward marker belongs below a closed bar when the fast average has moved from at or below the slow average to above it. A downward marker uses the reverse comparison. Nothing should be marked on the live unfinished bar.
Choose an editable marker offset in pips and require enough history for both averages. Historical and newly completed bars should follow the same rule. This indicator does not place orders, and a marker does not establish that a trade would be profitable.
Write a precise request
The following request sets a deliberately narrow scope. You can select its text directly; it stays readable even without JavaScript.
Create a cTrader C# overlay indicator, not a cBot. Use Close prices, fast SMA 20 and slow SMA 50 as editable inputs. Require positive periods with slow > fast and enough historical bars. Draw an upward marker below a completed bar when fast > slow on that bar and fast <= slow on the previous bar. Draw a downward marker above a completed bar for the reverse condition. Use an editable offset in pips. Do not create a signal on the live unfinished bar. Process the bar just closed when the next bar starts. Calculate the same markers on history. Use a stable object identifier per bar/direction to avoid duplicates. No orders, notifications, external services or file access. Explain how the closed-bar indexing and history calculation work. Provide complete source and identify assumptions requiring verification.
Generate and review the source with Xen
Open cTrader Xen and provide the requirements. Ask it to explain any assumptions and return the complete C# indicator source. Review whether the output is an indicator, uses the requested averages and handles the last closed bar consistently.
Keep a copy of the request and each source version. If a feature is unclear, resolve it before adding more features. This workflow does not depend on a particular Xen button or interface layout. Generated code still needs compilation and behavioural checks.
Build in cTrader Windows or Mac
- Install the development prerequisites listed in the current cTrader Algo documentation, including the .NET SDK. Open Algo in cTrader Windows or Mac; Web and Mobile are not the source development environment for this workflow.
- In Indicators, create a new C# indicator project with a suitable name. Replace the template source with the complete generated indicator source, preserving any required project files. Check that the project type and source class match the intended tool.
- Save and Build using the editor controls. Read the build result. If compilation fails, copy every error message, including its code and location; do not assume the first visible line is the only problem.
- After a successful build, open a demo chart and add the custom indicator through the chart’s indicator selector. Check the periods and offset before applying it.
Check historical signals and live behaviour
Add the standard moving averages with matching Close inputs for comparison. Inspect several upward and downward crossings and a period with no crossover. Check the equality boundary and the earliest bars where the slow average becomes available. A marker should belong to the bar defined by the specification, not the following bar.
Observe the current bar while it changes, then wait for a new bar. Confirm that a marker is added only for a qualifying completed bar. Reload the indicator and compare the historical markers with those seen live; a difference may indicate indexing or state problems. Record the chart period, settings and timestamp of any mismatch.
Report compiler errors precisely
Provide Xen with the complete current source, cTrader version and full compiler output as text. State that the requested repair should preserve the indicator’s closed-bar behaviour. Rebuild the returned version and repeat the same chart checks; compilation confirms the code can build, not that its markers are correct.
For a logic problem, give an exact symbol, period and bar time with time zone, the expected comparison and the observed result. Avoid “the arrows are wrong” without a reproducible example. Keep the last known working source before trying a revision.