DMI Multi timeframe

Created at 09 Apr 2023, 00:59
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!
ER

erotgertrading

Joined 09.04.2023

DMI Multi timeframe
09 Apr 2023, 00:59


Hi!

I need to modified this DMI indicator code in order to do that it can be use multi timframe. what i really need is to use this indicator in the 2 minute chart and that it shows the 10 minute chart values. can anyone help me?

The code that I need to modified is thisone:

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

namespace cAlgo
{
    [Indicator("DMS", IsOverlay = false, ScalePrecision = 0, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DirectionalMovementSystem : Indicator
    {
        [Parameter("Period", DefaultValue = 14, MinValue = 1)]
        public int Period { get; set; }

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

        [Output("ADX", Color = Colors.Cyan)]
        public IndicatorDataSeries ADX { get; set; }

        [Output("DI+", Color = Colors.Green)]
        public IndicatorDataSeries DiPlus { get; set; }

        [Output("Di-", Color = Colors.Red)]
        public IndicatorDataSeries DiMinus { get; set; }

        private DataSeries high, low, close;
        private IndicatorDataSeries tr, dmPlus, dmMinus, adx;
        private MovingAverage maTr, maDmPlus, maDmMinus, maAdx;

        protected override void Initialize()
        {
            high = MarketSeries.High;
            low = MarketSeries.Low;
            close = MarketSeries.Close;

            tr = CreateDataSeries();
            dmPlus = CreateDataSeries();
            dmMinus = CreateDataSeries();
            adx = CreateDataSeries();

            maTr = Indicators.MovingAverage(tr, Period, MaType);
            maDmPlus = Indicators.MovingAverage(dmPlus, Period, MaType);
            maDmMinus = Indicators.MovingAverage(dmMinus, Period, MaType);
            maAdx = Indicators.MovingAverage(adx, Period, MaType);
        }

        public override void Calculate(int index)
        {
            if (index == 0)
            {
                tr[0] = high[0] - low[0];
                dmPlus[0] = 0;
                dmMinus[0] = 0;
            }
            else
            {
                tr[index] = Math.Max(Math.Abs(low[index] - close[index - 1]), Math.Max(Math.Abs(high[index] - close[index - 1]), high[index] - low[index]));
                dmPlus[index] = high[index] - high[index - 1] > low[index - 1] - low[index] ? Math.Max(high[index] - high[index - 1], 0) : 0;
                dmMinus[index] = low[index - 1] - low[index] > high[index] - high[index - 1] ? Math.Max(low[index - 1] - low[index], 0) : 0;

                DiPlus[index] = 100 * (maTr.Result[index] == 0 ? 0 : maDmPlus.Result[index] / maTr.Result[index]);
                DiMinus[index] = 100 * (maTr.Result[index] == 0 ? 0 : maDmMinus.Result[index] / maTr.Result[index]);

                adx[index] = Math.Abs((DiPlus[index] - DiMinus[index]) / (DiPlus[index] + DiMinus[index]));
                ADX[index] = adx[index] == 0 ? 50 : 100 * maAdx.Result[index];
            }
        }
    }
}

 

Thanks!


@erotgertrading
Replies

PanagiotisChar
10 Apr 2023, 08:03

Hi there,

This is possible but needs some work. If you are interested in a quote, contact me at development@clickalgo.com 

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar