15 EUR
Closed

Calculating MA dynamic from ATR

Payment method:  Direct Payment Job posted on 24 Oct 2019, 13:44
Jan since: 05 Apr 2019

I would like to combine these to indicators so that the MA Dynamic values (line and histogram) are calculated from ATR values (and not from price as they are now).

In the new indicator, all public parameters are as in originals. All lines (ATR, MA & Histogram) are drawn in the same chart panel.

 

PayPal of Crypto (BTC, ETH, XMR or Dash) payment is made after the indicator is checked to work as intended and I have the source code. You can look at my profile at freelance for reference: https://www.freelancer.com/u/Fibonacci2011?w=f We can also do partial payment, but i don't see tha necessary for such a small project.

ATR Code:

// -------------------------------------------------------------------------------
//
//    Average True Range
//
// -------------------------------------------------------------------------------

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, ScalePrecision = 5, AccessRights = AccessRights.None)]
    public class AverageTrueRange : Indicator
    {
        [Parameter("Period", DefaultValue = 14)]
        public int Period { get; set; }


        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        private ExponentialMovingAverage _ema;
        private IndicatorDataSeries _tempBuffer;

        protected override void Initialize()
        {
            _tempBuffer = CreateDataSeries();
            _ema = Indicators.ExponentialMovingAverage(_tempBuffer, Period);
        }

        public override void Calculate(int index)
        {
            double high = MarketSeries.High[index];
            double low = MarketSeries.Low[index];

            if (index == 0)
            {
                _tempBuffer[index] = high - low;
            }
            else
            {
                double prevClose = MarketSeries.Close[index - 1];
                _tempBuffer[index] = Math.Max(high, prevClose) - Math.Min(low, prevClose);
            }

            Result[index] = _ema.Result[index];
        }
    }
}

 

MA Dynamic Code:

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

namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, ScalePrecision = 1, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MADynamics : Indicator
    {
        [Parameter(DefaultValue = 200)]
        public int Period { get; set; }
        [Parameter("Source")]
        public DataSeries Source { get; set; }
        [Parameter("Velocity LookBack", DefaultValue = 20)]
        public int Lookback { get; set; }
        [Parameter("Acceleration LookBack", DefaultValue = 20)]
        public int AccLookback { get; set; }
        [Parameter("Method", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType MAType { get; set; }

        [Output("Velocity", LineColor = "Cyan")]
        public IndicatorDataSeries Vel { get; set; }
        [Output("Acceleration", LineColor = "83FFFF01", PlotType = PlotType.Histogram)]
        public IndicatorDataSeries Acc { get; set; }

        private MovingAverage MA;

        protected override void Initialize()
        {
            MA = Indicators.MovingAverage(Source, Period, MAType);
            if (RunningMode == RunningMode.RealTime)
                IndicatorArea.DrawHorizontalLine("0", 0, Color.FromHex("78FFFFFF"));
        }

        public override void Calculate(int index)
        {
            Vel[index] = (MA.Result[index] - MA.Result[index - Lookback]) / Symbol.PipSize;
            Acc[index] = Vel[index] - Vel[index - AccLookback];
        }
    }
}

 

Ps.

I'm looking for programmers to co-op inbuilding cAlgo indicators and cBots. I'm currently working on to build a robust cBot template. Hopefully, I can find a programmer here to co-op. If you prefer, we can also work through Freelancer.

I want to do my best to support the cTrader environment, so I'm posting this here instead of at Freelancer

My username at Telegram is @Fibonacci2011, feel free to contact me for more info  :)

=========================================

 

Ths job is done, I will post indicator to the forum soon