Crashed in OnStart with ArgumentException: Incorrect parameters count. (Parameter 'parameterValues')
Created at 06 Apr 2024, 20:37
Crashed in OnStart with ArgumentException: Incorrect parameters count. (Parameter 'parameterValues')
06 Apr 2024, 20:37
Having a go at making a cBot nothing too complex just want to see how things perform and wether it is worth all the stress.
I have managed to get this far and it saves with no errors or faults however when starting it the message comes up:
Crashed in OnStart with ArgumentException: Incorrect parameters count. (Parameter 'parameterValues')
Can somebody please advise to where my errors are? First time coding so not a clue what I have done wrong -.-
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
private double _volumeInUnits;
private Supertrend _supertrend;
private ExponentialMovingAverage _ema200;
private DEMA200 _DEMA;
[Parameter("Volume (Lots)", DefaultValue = 0.01)]
public double VolumeInLots { get; set; }
[Parameter("Label", DefaultValue = "Label")]
public string Label { get; set; }
public Position[] BotPositions
{
get { return Positions.FindAll(Label); }
}
protected override void OnStart()
{
_volumeInUnits = Symbol.QuantityToVolumeInUnits(VolumeInLots);
_supertrend = Indicators.Supertrend(12, 3);
_ema200 = Indicators.ExponentialMovingAverage(Bars.ClosePrices, 200);
_DEMA = Indicators.GetIndicator<DEMA200> (Bars.ClosePrices, 200) ;
}
protected override void OnBar()
{
if (_supertrend.UpTrend.Last(1) < Bars.LowPrices.Last(1) && _supertrend.DownTrend.Last(2) > Bars.HighPrices.Last(2) && Bars.ClosePrices.Last(1) < _ema200.Result.Last(1) && Bars.ClosePrices.Last(1) < _DEMA.Result.Last(1))
{
ClosePositions(TradeType.Sell);
ExecuteMarketOrder(TradeType.Buy, SymbolName, _volumeInUnits, Label);
}
else if (_supertrend.DownTrend.Last(1) > Bars.HighPrices.Last(1) && _supertrend.UpTrend.Last(2) < Bars.LowPrices.Last(2) && Bars.ClosePrices.Last(1) > _ema200.Result.Last(1) && Bars.ClosePrices.Last(1) > _DEMA.Result.Last(1))
{
ClosePositions(TradeType.Buy);
ExecuteMarketOrder(TradeType.Sell, SymbolName, _volumeInUnits, Label);
}
}
private void ClosePositions(TradeType tradeType)
{
foreach (var position in BotPositions)
{
if (position.TradeType != tradeType)
continue;
ClosePosition(position);
}
}
}
}
PanagiotisCharalampous
07 Apr 2024, 06:19
Hi there,
The error message indicates that you have not passed all the necessary parameters to the DEMA200 indicator.
Best regards,
Panagiotis
@PanagiotisCharalampous