Quick Answer
Two C# compile errors say that a method call has the wrong number of arguments:
CS7036: There is no argument given that corresponds to the required parameter 'x' of 'Method(...)'means you left out an argument that the method requires. The message names the missing parameter.CS1501: No overload for method 'Method' takes N argumentsmeans that no version of the method accepts that many arguments. You passed too few, too many, or a count that no version supports.
Which of the two you see depends on how many versions (overloads) of the method exist. A method with a single version usually reports the missing parameter (CS7036). A method with several versions reports that none of them takes N arguments (CS1501). The cause and the fix are the same: compare your call with the parameter list of the method and add, remove or reorder arguments.
If the number of arguments is right and the type is wrong, the error is CS1503: cTrader C# error CS1503.
From the author: I build cBots in cTrader Automate and convert strategies from Pine Script and MQL5 to C#. These two errors appear when a call is written from memory of another platform or from an older example: the method name is right, but the list of arguments is not the one the method expects. This guide shows how to read each message and what to check first.
Key Facts
| What you see | Usual cause | Fix |
|---|---|---|
| CS7036 ... required parameter 'periods' | A required argument is missing | Add the argument named in the message |
| CS1501 No overload ... takes 2 arguments | No version of the method takes 2 | Pick the version you need and match its count |
| CS1501 No overload ... takes 9 arguments | Too many arguments, often from an MQL5 call | Remove the extra arguments |
| The call compiled before and fails now | An update changed the method or you changed the call | Compare with the current parameter list |
| Optional arguments in the middle | You skipped an optional argument that a later one needs | Pass the value or use a named argument |
Read the Message
CS7036: There is no argument given that corresponds to the required parameter
'periods' of 'IndicatorsAccessor.ExponentialMovingAverage(DataSeries, int)'
CS1501: No overload for method 'ExecuteMarketOrder' takes 2 arguments
- The method name tells you which call to look at.
- The parameter name (CS7036) is the argument you did not pass.
- The count (CS1501) is the number of arguments you did pass.
- The line points to the call.
The signature that CS7036 prints is a free parameter list for you: it shows the types and the names in the order the method wants them (the exact text of the signature in your editor can differ from the example above).
The Broken cBot
This cBot calls an indicator and a trade method. Each marked call has the wrong number of arguments. Depending on how many versions of a method exist, the compiler reports CS7036 or CS1501 for it:
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class BrokenBot : Robot
{
private ExponentialMovingAverage _ema;
protected override void OnStart()
{
_ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices); // missing the period
}
protected override void OnBar()
{
double ema = _ema.Result.Last(1);
if (Bars.ClosePrices.Last(1) > ema)
{
ExecuteMarketOrder(TradeType.Buy, SymbolName); // missing the volume
ExecuteMarketOrder(TradeType.Buy, SymbolName, 1000, "Broken", 20, 40, "comment", 0, 0); // too many
}
}
}
}
Cause 1: A Missing Required Argument
An indicator needs its source and its period, a trade call needs at least the direction, the symbol name and the volume. If you leave one out, the compiler cannot guess it:
_ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices); // missing the period
_ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 20); // correct
In Pine Script, ta.ema(close, 20) has the same two arguments, but a Pine function often has defaults that a C# method does not. A call that worked in Pine can therefore be one argument short in C#.
Cause 2: Too Many Arguments
A call that is copied from MQL5 usually has more arguments than the cTrader method, because MQL5 trade requests carry the price, the slippage, the magic number and more in the call. In cTrader, many of those things are not arguments:
| MQL5 idea | cTrader C# |
|---|---|
| Magic number | The label argument |
| Price for a market order | Not passed, the order is filled at the current price |
| Stop loss and take profit as prices | Pips in ExecuteMarketOrder, or ModifyPosition with prices |
| Expiration | A parameter of the pending order methods |
The conversion of the order calls is shown in Pine Script strategy.entry to cTrader C# and Pine Script strategy.exit to cTrader C#.
Cause 3: Skipping an Optional Argument
Many cTrader methods have optional parameters at the end (for example the label, the stop loss, the take profit and a comment). You may leave off the last ones. If you want to set a later one and skip an earlier one, pass a value for the skipped one, or name the argument:
// Set a take profit but no stop loss: pass null for the stop loss
ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, "Label", null, 40);
Passing null for an optional pip value means "no stop loss" for the methods that accept an empty value. Check the parameter type of the method first: null is allowed only for nullable parameters.
C# also supports named arguments (stopLossPips: 20), which make a long call easier to read and avoid argument-order mistakes. They need the exact parameter name from the method, which the editor shows.
Cause 4: A Different Version of the Method
The API of cTrader Automate changes between versions: methods are added, and older versions can be marked as outdated. Code from an old example may call a version that no longer exists with that count of arguments. When the same call worked in an older project, compare it with the parameter list in the current API reference, not with the old code.
How to See the Parameter List
- Type the method name and an opening bracket in the editor. The list of parameters shows, with the types and names, and the arrow keys switch between the versions of the method.
- Count your arguments and compare them with the version you want.
- Look at which parameters are optional. They have a default value in the list.
- Check the API reference of cTrader Automate for the method, if the editor does not show it.
The Fixed cBot
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class FixedBot : Robot
{
private const string Label = "FixedBot";
private ExponentialMovingAverage _ema;
protected override void OnStart()
{
_ema = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 20);
}
protected override void OnBar()
{
double close = Bars.ClosePrices.Last(1);
double ema = _ema.Result.Last(1);
if (double.IsNaN(close) || double.IsNaN(ema))
return;
Print("Close {0}, EMA {1}, close above EMA: {2}", close, ema, close > ema);
// The call below shows the number of arguments for a market order with a stop loss
// and a take profit in pips. Uncomment it only in a demo test.
// var volume = Symbol.NormalizeVolumeInUnits(1000, RoundingMode.Down);
// ExecuteMarketOrder(TradeType.Buy, SymbolName, volume, Label, 20, 40);
}
}
}
The bot prints first so that you can compare the values with the chart. The order call stays commented out until the numbers are right.
Similar Errors
| Error | Message | What it means | |---|---|---| | CS7036 | No argument given that corresponds to the required parameter | A required argument is missing | | CS1501 | No overload for method takes N arguments | No version takes that many arguments | | CS1503 | Argument N: cannot convert from 'A' to 'B' | The count is right, one type is wrong | | CS1061 | 'X' does not contain a definition for 'Y' | The member after the dot does not exist | | CS0103 | The name 'x' does not exist in the current context | A name is unknown |
Checklist: What to Check When You See CS7036 or CS1501
- Read the method name and, for CS7036, the missing parameter.
- Open the parameter list in the editor and count the arguments.
- Required or optional? Add the required ones, and drop or reorder the extra ones.
- From MQL5? Remove the arguments that cTrader does not take (price, slippage, magic number).
- Skipped an optional one? Pass
nullwhere the type allows it, or use a named argument. - Old example? Compare with the current API reference.
- Build again after each fix. One wrong call can hide others.
- When it builds, print the values, compare with the chart and test on a demo account.
Common Mistakes
- Copying a trade call from MQL5 with all its arguments.
- Forgetting the period in an indicator call.
- Skipping an optional argument in the middle without passing a value.
- Using an old example for a method that has changed.
- Guessing the order of arguments instead of reading the list.
- Ignoring the parameter name in the CS7036 message.
FAQ
Related Guides
- cTrader C# error CS1503: the count is right, the type is wrong.
- cTrader C# error CS0266: a
doublestored in anint. - cTrader C# error CS1061: the object is found, the member is not.
- cTrader C# error CS0103: the name does not exist in the current context.
- Pine Script strategy.entry to cTrader C#: market and pending orders with the right arguments.
- MQL5 wrong parameters count error: the MetaEditor version of the same problem.
- What to check in a trading bot before going live: a pre-live checklist for stops, lot size, spread and trade results.
Fix Compile Errors Without Guessing
If a cBot or an Expert Advisor 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 backtest it before using it on a live account.