Quick Answer
The C# error CS0535 ("... does not implement interface member ...") means that a class lists an interface after its name, and does not provide every member that the interface declares. The Microsoft reference gives the fix in one line: provide an implementation for every member of the interface, or declare the class abstract. You see it in a cBot when you split your strategy into small classes (a signal, a risk rule, a trailing rule) that share an interface.
Several close errors have the same family: CS0737 (the member is not public), CS0736 (it is static), CS0738 (the return type does not match), CS0540 (an explicit implementation, but the interface is not listed on the class) and CS0539 (the explicit member is not in the interface). This post shows one small interface, the class that triggers each error, the fix, and a cBot that prints a result. It is not the same as CS0534, which is about a cBot or indicator that misses an abstract member of the cTrader base class (see CS0534).
From the author: I convert MQL5 and Pine code to cTrader C#. When an MQL5 program has a base class with a pure virtual method, the natural C# form is an interface or an abstract class, and the first version usually misses the
public. The compiler is clear about it. The problem is only that the message is long.
Key Facts
| Error | What it means (Microsoft reference) | Fix |
|---|---|---|
| CS0535 | The class does not implement every member of the interface | Add the missing member, or make the class abstract |
| CS0737 | The implementing member is not public | Add public |
| CS0736 | The implementing member is static | Remove static |
| CS0738 | The return type differs from the interface member | Use exactly the same return type |
| CS0540 | An explicit implementation exists, but the class does not list the interface | Add the interface to the class, or remove the member |
| CS0539 | The explicit member is not found in the interface | Check the name and the signature |
The rows come from the Microsoft compiler-error reference pages. They describe the language, not cTrader. I checked no cTrader-specific behavior for this post.
The Interface Used in the Examples
A small interface for a trading signal:
public interface ISignal
{
bool ShouldBuy(int index);
string Name { get; }
}
Two members: a method and a read-only property. A class that implements the interface must have both, both public, with the same types.
CS0535: A Member Is Missing
public class MaSignal : ISignal // CS0535: 'MaSignal' does not implement 'ISignal.Name'
{
public bool ShouldBuy(int index)
{
return index % 2 == 0;
}
}
The class has ShouldBuy and no Name. The fix is to add the member:
public class MaSignal : ISignal
{
public string Name { get { return "MA signal"; } }
public bool ShouldBuy(int index)
{
return index % 2 == 0;
}
}
The compiler message names the missing member, so read it before you scroll through the code. If you really want a class that implements only part of an interface, make it abstract and let a subclass finish it.
CS0737: The Member Is Not Public
public class RsiSignal : ISignal
{
public string Name { get { return "RSI signal"; } }
bool ShouldBuy(int index) // no access modifier = private: CS0737
{
return index > 10;
}
}
In C# a class member is private when you write no modifier. An interface member is public, so the class member that implements it must be public too. Write public bool ShouldBuy(int index).
CS0738: The Return Type Does Not Match
public class BreakoutSignal : ISignal
{
public string Name { get { return "Breakout"; } }
public int ShouldBuy(int index) // CS0738: the interface says bool
{
return 1;
}
}
A common reason is code that was converted from MQL5, where 1 and 0 are often used as true and false. Use bool and compare in the method.
CS0736: A Static Member
If the interface method is an instance member, the class method must not be static. A static helper that you wrote for a utility class cannot satisfy the interface. Remove static, and if you need a shared helper, call a static method from inside the instance method.
CS0540 and CS0539: Explicit Implementations
An explicit implementation names the interface in the member:
public class ExplicitSignal // CS0540: the interface is not listed on the class
{
bool ISignal.ShouldBuy(int index)
{
return true;
}
}
Add : ISignal to the class to fix CS0540. If you spell the member differently from the interface (ShouldBuyNow), you get CS0539, because the interface has no such member. Compare the name and the parameter list with the interface.
A cBot That Prints a Result You Can Check
This cBot does not trade. It uses the fixed MaSignal and prints the signal on three indexes:
using System;
using cAlgo.API;
namespace cAlgo.Robots
{
public interface ISignal
{
bool ShouldBuy(int index);
string Name { get; }
}
public class MaSignal : ISignal
{
public string Name { get { return "MA signal"; } }
public bool ShouldBuy(int index)
{
return index % 2 == 0;
}
}
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SignalTest : Robot
{
protected override void OnStart()
{
ISignal signal = new MaSignal();
for (int i = 0; i < 3; i++)
Print("{0} at {1}: {2}", signal.Name, i, signal.ShouldBuy(i));
Stop();
}
}
}
The expected log is MA signal at 0: True, MA signal at 1: False, MA signal at 2: True (checked by hand, the cBot was not built). If you remove the Name property from MaSignal the build fails with CS0535.
Interface or Abstract Class?
| You want | Use | |---|---| | Several unrelated classes with the same methods | An interface | | Shared code plus a few methods that each class must write | An abstract class | | To keep it simple in a first cBot | Neither: one class with a method |
An interface is also handy when you want to swap a signal in a test. For a first converted cBot, a few methods in the cBot class are often enough.
Similar cTrader Messages
| Message | What it means | Where to look | |---|---|---| | CS0535 | A class misses an interface member | This post | | CS0534 | A class misses an abstract member of its base class | CS0534 | | CS0115 | No method found to override | CS0115 | | CS0161 | Not all code paths return a value | CS0161 | | CS0120 | An object reference is required | CS0120 | | CS0246 | A type or namespace is not found | CS0246 |
Checklist: What to Check When You See CS0535
- Read the member that the message names.
- Compare the class with the interface, member by member.
- Add
publicto every implementing member. - Match the return type and the parameters exactly.
- Remove
staticfrom an implementing method. - List the interface on the class if you use explicit members.
- Use
abstractif the class is meant to be partial. - Build again, and fix the next error.
Common Mistakes
- Forgetting
publicon an implementing member. - Returning
intwhere the interface saysbool. - Implementing a method and forgetting the property.
- A
statichelper used as an interface member. - Misspelling an explicit member.
- Mixing up CS0535 with CS0534.
FAQ
Related Guides
- cTrader error CS0534: does not implement inherited abstract member: the cBot and indicator version of this error.
- cTrader error CS0115: no suitable method found to override: handler names and signatures.
- cTrader error CS0161: not all code paths return a value: a method without a return.
- cTrader error CS0120: an object reference is required: static and instance members.
- cTrader error CS0246: type or namespace not found: a missing using.
- cTrader error CS1061: does not contain a definition: a member that does not exist.
- Pine Script to cTrader C# cBot: the full conversion process.
- What to check in a trading bot before going live: a pre-live checklist.
- cTrader cBot crashed: Error # with a long number: find the exception behind a crash.
Fix Compile Errors Without Guessing
If a cBot does not build, paste the code and the error message into the CodeFlowOS Error Fixer. It suggests a minimal fix, explains each error and shows what changed. A fix uses 1 credit, with up to 3 attempts included, and the compiler check is optional. Outputs are not guaranteed, and code that compiles can still have wrong trading logic, so always review the result. Before a bot goes live, the Code Review is free during the early-bird period. CodeFlowOS also converts strategies between Pine Script, MQL5 and cTrader C#: try the converter page.
This article is educational. It does not describe trading performance and is not financial advice. Always build the code in cTrader Automate and test it on a demo account before using it on a live account.