Indicator personlized. Error Crashed in Initialize with ArgumentException: Incorrect parameters count. Nombre del parámetro: parameterValues

Created at 23 Apr 2019, 19:51
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
EN

enrikeyo

Joined 23.04.2019

Indicator personlized. Error Crashed in Initialize with ArgumentException: Incorrect parameters count. Nombre del parámetro: parameterValues
23 Apr 2019, 19:51


I hace these indicators

Indicator 1:

using System;
using cAlgo;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class NemethHA : Indicator
    {

        [Output("Close", Color = Colors.AliceBlue, PlotType = PlotType.Histogram)]
        public IndicatorDataSeries haClose { get; set; }


        protected override void Initialize()
        {

        }

        public override void Calculate(int index)
        {
            double open = MarketSeries.Open[index];
            double high = MarketSeries.High[index];
            double low = MarketSeries.Low[index];
            double close = MarketSeries.Close[index];

            haClose[index] = (open + high + low + close) / 4;

        }
    }
}

 

Indicator 2 referencing indicator 1

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class Nemeth2 : Indicator
    {

        [Output("Resultado", Color = Colors.Orange, PlotType = PlotType.Histogram)]
        public IndicatorDataSeries Result { get; set; }

        private NemethHA nemethHAH4;
        private Exception exc;

        protected override void Initialize()
        {

            try
            {
                this.nemethHAH4 = Indicators.GetIndicator<NemethHA>(MarketSeries.Close);

            } catch (Exception e)
            {
                exc = e;
                throw e;
                Print(e.Message);
                Print(e.StackTrace);
            }
        }

        public override void Calculate(int index)
        {
            Print("nemethHAH4 es nulo " + (this.nemethHAH4 == null ? " si" : " no") + " exc " + (exc == null ? " null " : exc.Message));

            Result[index] = 1.0;
        }
    }

}

 

But its failed whith error

Crashed in Initialize with ArgumentException: Incorrect parameters count. Nombre del parámetro: parameterValues.

I cant see where is the error.

Please, help me.

 


@enrikeyo
Replies

PanagiotisCharalampous
24 Apr 2019, 10:10

Hi enrikeyo,

Thank you for posting in our forum. The issue is in the following line of code

this.nemethHAH4 = Indicators.GetIndicator<NemethHA>(MarketSeries.Close);

You are initializing an indicator with a parameter, however the indicator does not take any input parameters.

Best Regards,

Panagiotis


@PanagiotisCharalampous