Load and access values from external indicator?

Created at 23 Sep 2020, 17:27
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!
AR

arthur.albert990

Joined 23.09.2020

Load and access values from external indicator?
23 Sep 2020, 17:27



Hello, I'm trying to build a indicator that uses a custom indicator called Zero Lag MACD but I'm unable to load and access the indicator values.
After attaching it to chart, the bottom window is created but Histogram and Values from the MACD doesn't show on screen, remaining an empty black box.
 

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

namespace cAlgo
{
//
//
// AINDA NÃO ESTÁ FUNCIONANDO.
//

    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CLMACDAlbert : Indicator
    {
        [Parameter(DefaultValue = 150)]
        public int PeriodoLongo { get; set; }

        [Parameter(DefaultValue = 30)]
        public int PeriodoCurto { get; set; }

        [Parameter(DefaultValue = 60)]
        public int PeriodoSinal { get; set; }

        private ZeroLagMACD _macd;
        // declara o _macd?

        protected override void Initialize()
        {
            Print("Inicializando Zero-Lag MACD");
            _macd = Indicators.GetIndicator<ZeroLagMACD>(PeriodoLongo, PeriodoCurto, PeriodoSinal);
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...
        }
    }
}


Regards;


@arthur.albert990
Replies

PanagiotisCharalampous
24 Sep 2020, 07:51

Hi arthur.albert990,

It does not display anything because you do not have any output. Read here how to create a custom indicator.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

arthur.albert990
24 Sep 2020, 16:00

RE: No Result from Macd?

PanagiotisCharalampous said:

Hi arthur.albert990,

It does not display anything because you do not have any output. Read here how to create a custom indicator.

Best Regards,

Panagiotis 

Join us on Telegram

Hello PanagiotisCharalampous, i've tried to add an output to the code and the "Result" on Calculate() but i'm unable to obtain the result from macd, platform tells me that the ZeroLagMACD doesn't has a definition for Result.

Code below. Thank you for your time, have a good day!
 

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

namespace cAlgo
{

    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CLMACDAlbert : Indicator
    {

        [Parameter(DefaultValue = 150)]
        public int PeriodoLongo { get; set; }

        [Parameter(DefaultValue = 30)]
        public int PeriodoCurto { get; set; }

        [Parameter(DefaultValue = 60)]
        public int PeriodoSinal { get; set; }

        private ZeroLagMACD _macd;

        [Output("Zero Lag MACD Output")]
        public IndicatorDataSeries Result { get; set; }


        protected override void Initialize()
        {
            Print("Inicializando Zero Lag MACD");
            _macd = Indicators.GetIndicator<ZeroLagMACD>(PeriodoLongo, PeriodoCurto, PeriodoSinal);
        }

        public override void Calculate(int index)
        {
            Result[index] = _macd.Result[index];
        }
    }
}

 


@arthur.albert990

PanagiotisCharalampous
24 Sep 2020, 16:06

Hi arthur.albert990,

Hello PanagiotisCharalampous, i've tried to add an output to the code and the "Result" on Calculate() but i'm unable to obtain the result from macd, platform tells me that the ZeroLagMACD doesn't has a definition for Result.

If this is the indicator you use, then it doesn't :)

Here are your options

        [Output("Histogram", Color = Colors.Turquoise, PlotType = PlotType.Histogram)]
        public IndicatorDataSeries Histogram { get; set; }
 
        [Output("MACD", Color = Colors.Blue)]
        public IndicatorDataSeries MACD { get; set; }
 
        [Output("Signal", Color = Colors.Red, LineStyle = LineStyle.Lines)]
        public IndicatorDataSeries Signal { get; set; }

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous