How do I use Di DI Indicator

Created at 04 Oct 2023, 11: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!
Luxor's avatar

Luxor

Joined 09.04.2023

How do I use Di DI Indicator
04 Oct 2023, 11:27


Someone could help me to use in cbot the famus indicador “didi”???

 

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.ESouthAmericaStandardTime, AccessRights = AccessRights.None)]
    public class DidiIndex : Indicator
    {
        [Parameter("Short Source")]
        public DataSeries ShortSource { get; set; }

        [Parameter(DefaultValue = 3)]
        public int ShortPeriods { get; set; }

        [Output("Short Color", Color = Colors.Lime)]
        public IndicatorDataSeries ShortResult { get; set; }

        [Parameter("Main Source")]
        public DataSeries MainSource { get; set; }

        [Parameter(DefaultValue = 8)]
        public int MainPeriods { get; set; }

        [Output("Main Color", Color = Colors.White)]
        public IndicatorDataSeries MainResult { get; set; }

        [Parameter("Long Source")]
        public DataSeries LongSource { get; set; }

        [Parameter(DefaultValue = 20)]
        public int LongPeriods { get; set; }

        [Output("Long Color", Color = Colors.Yellow)]
        public IndicatorDataSeries LongResult { get; set; }

        public override void Calculate(int index)
        {
            double sum;

            sum = 0.0;
            for (int i = index - MainPeriods + 1; i <= index; i++)
            {
                sum += MainSource[i];
            }
            MainResult[index] = sum / MainPeriods;

            sum = 0.0;
            for (int i = index - ShortPeriods + 1; i <= index; i++)
            {
                sum += ShortSource[i];
            }
            ShortResult[index] = sum / ShortPeriods;

            sum = 0.0;
            for (int i = index - LongPeriods + 1; i <= index; i++)
            {
                sum += LongSource[i];
            }
            LongResult[index] = sum / LongPeriods;

            ShortResult[index] /= MainResult[index];
            LongResult[index] /= MainResult[index];
            MainResult[index] = 1;
        }
    }
}


@Luxor
Replies

PanagiotisChar
05 Oct 2023, 05:44

Hi there,

What exact help do you need? Somebody to write the cBot for you? Or do you have any specific question?

 


@PanagiotisChar