Calling an indicator From an indicator, Result is NaN
            
                 26 Apr 2020, 16:55
            
                    
Hello,
First of all thanks for such good platform.
I am calling an indicator from another indicator as described in documentation. While Sample EMA is working mine does not. Here is Indicator i use:
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
    [Indicator("Induk", IsOverlay = false, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class Induk : Indicator
    {
        [Parameter(DefaultValue = 55)]
        public int period { get; set; }
        [Parameter()]
        public DataSeries SourceHigh { get; set; }
        [Parameter()]
        public DataSeries SourceLow { get; set; }
        [Parameter()]
        public DataSeries SourceClose { get; set; }
        [OutputAttribute("Main1", LineColor = "Red")]
        public IndicatorDataSeries Result1 { get; set; }
        [OutputAttribute("Main2", LineColor = "Green")]
        public IndicatorDataSeries Result2 { get; set; }
        [OutputAttribute("Main3", LineColor = "White")]
        public IndicatorDataSeries Result3 { get; set; }
        private int lastCalculatedIndex = 0;
        protected override void Initialize()
        {
            //
        }
        public override void Calculate(int index)
        {
            // Yeterli bar oluncaya kadar bekle
            if (index < (period + 1))
            {
                return;
            }
            if (IsLastBar)
            {
                return;
            }
            // Do not calculate same bar again
            if (lastCalculatedIndex == index)
            {
                return;
            }
            lastCalculatedIndex = index;
            Result1[index] = 1;
            Result2[index] = 2;
            Result3[index] = 3;
        }
    }
}
And here is my second indicator which tries to use the one above:
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
    [Indicator("IndukCaller", IsOverlay = false, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class IndukCaller : Indicator
    {
        private Induk induk;
        private int lastCalculatedIndex = 0;
        private int period = 55;
        protected override void Initialize()
        {
            induk = Indicators.GetIndicator<Induk>(period, Bars.HighPrices, Bars.LowPrices, Bars.ClosePrices);
        }
        public override void Calculate(int index)
        {
            // Yeterli bar oluncaya kadar bekle
            if (index < (period + 1))
            {
                return;
            }
            if (IsLastBar)
            {
                return;
            }
            // Do not calculate same bar again
            if (lastCalculatedIndex == index)
            {
                return;
            }
            lastCalculatedIndex = index;
            Print("Index: {0} => induk.1: {1}", index, induk.Result1[index]);
        }
    }
}
Manage reference mark 's marked.

Using cTrader 3.7 Desktop in Windows 10.
Here is sample output:

Best
Replies
                     PanagiotisCharalampous
                     27 Apr 2020, 12:02
                                    
Hi ergun,
Yes this is correct because the referenced indicator does not know how many bars are to be calculated yet.
Best Regards,
Panagiotis
@PanagiotisCharalampous

PanagiotisCharalampous
27 Apr 2020, 10:10
Hi ergun,
If you remove the following code, it should work fine
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous