Parameter type "cAlgo.API.Bars" is not supported.

Created at 31 Mar 2025, 17:00
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!
PA

pasisa

Joined 14.02.2025

Parameter type "cAlgo.API.Bars" is not supported.
31 Mar 2025, 17:00


Hello,
I want to develop a relatively simple indicator based on another existing indicator: 'DirectionalMovementSystem'.
 

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

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None)]
    public class ADX_Tendance : Indicator
    {
        [Parameter("Source")]
        public Bars Source { get; set; }
        
        [Parameter("ADX Period", DefaultValue = 14)]
        public int DMIPeriod { get; set; }

        [Parameter("HMA Period", DefaultValue = 20)]
        public int EmaPeriod { get; set; }
        
        [Output("Custom ADX Result", LineColor = "Blue", PlotType = PlotType.Line)]
        public IndicatorDataSeries Result { get; set; }

        private DirectionalMovementSystem _dmi;
        private ExponentialMovingAverage _mme;
        private IndicatorDataSeries _rawResult;
        private IndicatorDataSeries _moyResult;
        

        protected override void Initialize()
        {
            //Source = MarketData.GetBars(SourceTimeFrame);
            _dmi = Indicators.DirectionalMovementSystem(Source, DMIPeriod);
            _rawResult = CreateDataSeries();
            _moyResult = CreateDataSeries();
            _mme = Indicators.ExponentialMovingAverage(_rawResult, EmaPeriod);
        }

        public override void Calculate(int index)
        {
            double diPlus = _dmi.DIPlus[index];
            double diMinus = _dmi.DIMinus[index];
            double adxValue = _dmi.ADX[index];

            _rawResult[index] = (diPlus - diMinus) * adxValue;
            _moyResult[index] = _mme.Result[index]; 
            
            if(_moyResult[index] < -100) 
                Result[index] = -1;
            else if (_moyResult[index] > 100)
                Result[index] = 1;
            else
                Result[index] = 0;
        }
    }
}

When I try to generate the code, it returns an error:

 

Could you help me understand and resolve this problem?

Thank you in advance.

 

 


@pasisa
Replies

firemyst
03 Apr 2025, 07:43

You can't have a parameter of type “Bars”. 

 

 


@firemyst