Zero-Lag moving average free

by qualitiedx2 in category Trend at 16/05/2012
Description

Zero Lag MA is an indicator that attempts to remove the lagging characteristics of indicators like the Exponential Moving Average. It does this by tracking current prices more closely than previous prices.

 ZeroLag Moving Average

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
using cAlgo.API;
using cAlgo.API.Indicators;

namespace MoneyBiz.cAlgo.Indicators
{
    [Indicator("Zero Lag Moving Average (ZLMA)", ScalePrecision = 5, IsOverlay = true)]
    public class ZeroLagMovingAverage : Indicator
    {
        private MovingAverage _ma1;
        private MovingAverage _ma2;

        [Parameter("Data Source")]
        public DataSeries DataSource { get; set; }

        [Parameter("Moving Average Type", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType MovingAverageType { get; set; }

        [Parameter("Periods", DefaultValue = 7, MinValue = 1)]
        public int Periods { get; set; }

        [Parameter("Correction Factor", DefaultValue = 0.7d, MinValue = 0.0d, MaxValue = 1.0d)]
        public double CorrectionFactor { get; set; }

        [Output("Result", Color = Colors.Red, LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries Result { get; protected set; }

        public override void Calculate(int index)
        {
            _ma1.Calculate(index);
            _ma2.Calculate(index);

            var diff = _ma1.Result[index] - _ma2.Result[index];

            Result[index] = _ma1.Result[index] + CorrectionFactor*diff;
        }

        protected override void Initialize()
        {
            _ma1 = Indicators.MovingAverage(DataSource, Periods, MovingAverageType);
            _ma2 = Indicators.MovingAverage(_ma1.Result, Periods, MovingAverageType);

            base.Initialize();
        }
    }
}
Comments

bisedo2527 - September 19, 2022 @ 15:35

at least specify what timeframe it should be used on...

Try FFH4X Mod Menu and access some great tools for free.

5