I'm getting the Error #495797

Created at 11 Apr 2020, 07:42
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!
andresort28's avatar

andresort28

Joined 13.09.2015

I'm getting the Error #495797
11 Apr 2020, 07:42


I developed an indicator based on a Moving Average, and the build was correct, but when I attached this custom indicator to the chart I get the error #496707 in the log area. I would like to know why this error is appearing and what means "Can not create instance".


@andresort28
Replies

PanagiotisCharalampous
13 Apr 2020, 08:44

Hi andresort28,

Can you please post the indicator code and let us know which broker you use?

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

andresort28
17 Apr 2020, 07:00

RE:
  • PanagiotisCharalampous said:

Hi andresort28,

Can you please post the indicator code and let us know which broker you use?

Best Regards,

Panagiotis 

Join us on Telegram

 

Hi Panagiotis,
I attached my indicator code. I'm using FxPro as my broker.
Please help me to know which is wrong and why I'm getting that error.

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class HeikenAshiSmoothed : Indicator
    {
        [Parameter("Open")]
        public static DataSeries Source_Open { get; set; }

        [Parameter("Close")]
        public DataSeries Source_Close { get; set; }

        [Parameter("High")]
        public DataSeries Source_High { get; set; }

        [Parameter("Low")]
        public DataSeries Source_Low { get; set; }

        [Parameter(DefaultValue = 50, MinValue = 1)]
        public int Periods { get; set; }

        [Parameter("MA Type", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType MAType { get; set; }

        public const string START_ROW = "\n\n\n";
        private Color color_up = Color.LawnGreen;
        private Color color_down = Color.Red;

        private MovingAverage maOpen;
        private MovingAverage maClose;
        private MovingAverage maHigh;
        private MovingAverage maLow;
        private IndicatorDataSeries haClose;
        private IndicatorDataSeries haOpen;

        private int count;
        private int index_actual;
        private Color color_close;


        protected override void Initialize()
        {
            Print("Initialize HA");
            maOpen = Indicators.MovingAverage(Source_Open, Periods, MAType);
            maClose = Indicators.MovingAverage(Source_Close, Periods, MAType);
            maHigh = Indicators.MovingAverage(Source_High, Periods, MAType);
            maLow = Indicators.MovingAverage(Source_Low, Periods, MAType);

            haOpen = CreateDataSeries();
            haClose = CreateDataSeries();

            count = 0;
        }

        public override void Calculate(int index)
        {
            count++;
            string t1 = START_ROW + "Count:\t" + count;
            string t2 = "\nIndex:\t" + index;
            Chart.DrawStaticText("data", t1 + t2, VerticalAlignment.Top, HorizontalAlignment.Left, Color.LightBlue);

            double haHigh;
            double haLow;
            Color colorCandle;

            if (index > index_actual)
            {
                index_actual = index;

                Chart.DrawStaticText("Label_Close", START_ROW + "\n\n" + "Close:", VerticalAlignment.Top, HorizontalAlignment.Left, Color.LightBlue);

                if (color_close == color_up)
                    Chart.DrawStaticText("close_data", START_ROW + "\n\n" + "\tUp", VerticalAlignment.Top, HorizontalAlignment.Left, color_up);
                if (color_close == color_down)
                    Chart.DrawStaticText("close_data", START_ROW + "\n\n" + "\tDown", VerticalAlignment.Top, HorizontalAlignment.Left, color_down);
            }

            if (index > 0 && !double.IsNaN(maOpen.Result[index - 1]))
            {
                haOpen[index] = (haOpen[index - 1] + haClose[index - 1]) / 2;
                haClose[index] = (maOpen.Result[index] + maClose.Result[index] + maHigh.Result[index] + maLow.Result[index]) / 4;
                haHigh = Math.Max(maHigh.Result[index], Math.Max(haOpen[index], haClose[index]));
                haLow = Math.Min(maLow.Result[index], Math.Min(haOpen[index], haClose[index]));
                colorCandle = (haOpen[index] > haClose[index]) ? color_down : color_up;

                color_close = colorCandle;
                Chart.DrawStaticText("Label_Value", START_ROW + "\n\n\n" + "Value:", VerticalAlignment.Top, HorizontalAlignment.Left, Color.LightBlue);

                if (color_close == color_up)
                    Chart.DrawStaticText("value_data", START_ROW + "\n\n\n" + "\tUp", VerticalAlignment.Top, HorizontalAlignment.Left, color_up);
                if (color_close == color_down)
                    Chart.DrawStaticText("value_data", START_ROW + "\n\n\n" + "\tDown", VerticalAlignment.Top, HorizontalAlignment.Left, color_down);


                Chart.DrawRectangle("BarHA" + index, index, haOpen[index], index, haClose[index], colorCandle, 5, LineStyle.Solid);
                Chart.DrawRectangle("LineHA" + index, index, haHigh, index, haLow, colorCandle, 1, LineStyle.Solid);


                //Print("Count:\t" + count + "\t\tIndex:\t" + index + "\t\tColor:\t" + Color.ToString());
            }
            else if (!double.IsNaN(maOpen.Result[index]))
            {
                haOpen[index] = (maOpen.Result[index] + maClose.Result[index]) / 2;
                haClose[index] = (maOpen.Result[index] + maClose.Result[index] + maHigh.Result[index] + maLow.Result[index]) / 4;
                haHigh = maHigh.Result[index];
                haLow = maLow.Result[index];

                Chart.DrawStaticText("data", "INTO ELSE", VerticalAlignment.Top, HorizontalAlignment.Left, Color.Yellow);
            }
        }
    }
}

 


@andresort28

PanagiotisCharalampous
21 Apr 2020, 12:44

Hi andresort28,

To fix the issue, please remove the static keyword from

[Parameter("Open")]
public static DataSeries Source_Open { get; set; }

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous