Replies

enrikeyo
07 Jun 2019, 12:31

RE:

Panagiotis Charalampous said:

Hi enrikeyo,

Thanks for posting in our forum. The reason you get this behavior is because the indices do not match. Here is the correct way to do it.

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

namespace cAlgo
{
    [Indicator(TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
    public class Incidencia : Indicator
    {

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

        private MarketSeries marketSeriesXAUUSD;

        protected override void Initialize()
        {
            // Serie del XAUUSD
            this.marketSeriesXAUUSD = MarketData.GetSeries(MarketData.GetSymbol("XAUUSD"), MarketSeries.TimeFrame);
            Print("Inicializado ");
        }

        public override void Calculate(int index)
        {
            // Print(this.marketSeriesXAUUSD.SymbolCode);
            Resultado[index] = this.marketSeriesXAUUSD.Close[marketSeriesXAUUSD.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index])];
        }

    }
}

Best Regards,

Panagiotis

 

Thank you, very much

 


@enrikeyo