Category Oscilators  Published on 12/09/2019

MA Dynamics

Description

Follow my cTrader Telegram group at https://t.me/cTraderCommunity; everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ https://discord.gg/5GAPMtp and an Instagram page https://www.instagram.com/ctrader_community/

This oscillator shows Velocity and Acceleration for the selected MA


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];
        }
    }
}


CY
cysecsbin.01

Joined on 10.11.2018 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: MA Dynamics.algo
  • Rating: 0
  • Installs: 1433
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.