Skip to content

Using Xen Code in cTrader

You can download a built add-on from Xen and open it in cTrader, or copy the source code into a cTrader project. Downloading the built add-on avoids the source-project configuration steps below.

Copying source into a new project

New cTrader cBot and indicator projects can contain a main source file, config.json and GlobalUsings.cs. The configuration file defines settings and parameters separately from the source.

Xen’s complete source examples declare these settings directly in C# using attributes such as [Robot], [Indicator] and [Parameter]. cTrader supports this format, but you cannot combine it with config.json in the same project.

Before building copied source, prepare your project as follows:

  1. Remove config.json from the target cBot or indicator project.
  2. Open that project’s .csproj file and remove the following reference if it is still present:

    <AdditionalFiles Include="config.json" />
    
  3. If the surrounding <ItemGroup> is now empty, remove it too. Keep any other entries in that group.

  4. Replace the main template source with the complete code copied from Xen, save the project and rebuild.

For example, remove this entire group when it contains only the configuration reference:

<ItemGroup>
  <AdditionalFiles Include="config.json" />
</ItemGroup>

You can keep GlobalUsings.cs; it supplies shared namespace imports and does not cause the configuration conflict. Existing projects that already use source attributes and have no config.json reference need no configuration change.

Understanding the build errors

CGEN006, mentioning RobotAttribute, IndicatorAttribute or ParameterAttribute, means the project is mixing configuration from config.json with attributes in the source. Remove the configuration file and its project reference as described above; retain the attributes in Xen’s source.

If the build reports a missing config.json after deleting it, the .csproj file still references it. Remove the AdditionalFiles entry, save and rebuild.

These errors concern the project configuration. Resolve them before investigating any remaining source-code errors.

Copy notice

Xen displays a reminder after copying source that contains configuration attributes. Choose Don’t show again and Got it to hide future reminders in that browser. The notice links back to this page.