Category Trend  Published on 27/07/2023

Jurik Smooth MovingAverage

An update for this algorithm is currently pending moderation. Please revisit this page shortly to access the algorithm's latest version.
Description

The indicator displays on the price chart a moving average with the JSmooth smoothing type (the smoothing type proposed by Mark Jurik).




mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mJSmoothMA.algo
  • Rating: 5
  • Installs: 496
  • Modified: 27/07/2023 11:13
Comments
Log in to add a comment.
DA
dariohilll8 · 1 year ago

Please continue to support Drift Hunters and join me in discovering the next exciting things the game has to offer!

mfejza's avatar
mfejza · 1 year ago

for unknown some reasons I can not upload source code of indicator. please get it from comnet content

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class mJSmoothMA : Indicator
    {
        [Parameter("Periods (20)", DefaultValue = 20)]
        public int inpPeriod { get; set; }

        [Output("MarkJuric Smooth MovingAverage", LineColor = "Orange", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries outJSMA { get; set; }
        
        private double alpha, alpha1, alpha2;
        private IndicatorDataSeries _a1, _a2, _a3, _a4, _jsma;
        

        protected override void Initialize()
        {
            alpha = 0.45 * (inpPeriod - 1) / (0.45 * (inpPeriod - 1) + 2);
            alpha1 = alpha * alpha;
            alpha2 = (1 - alpha) * (1 - alpha);
            _a1 = CreateDataSeries();
            _a2 = CreateDataSeries();
            _a3 = CreateDataSeries();
            _a4 = CreateDataSeries();
            _jsma = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            _a1[i] = (1 - alpha) * Bars.ClosePrices[i] + alpha * (i>1 ? _a1[i-1] : 0);
            _a2[i] = (1 - alpha) * (Bars.ClosePrices[i] - _a1[i]) + alpha * (i>1 ? _a2[i-1] : 0);
            _a3[i] = _a1[i] + _a2[i];
            _a4[i] = (_a3[i] - (i>1 ? _jsma[i-1] : Bars.ClosePrices[i])) * alpha2 + alpha1 * (i>1 ? _a4[i-1] : 0);
            _jsma[i] = (i>1 ? _jsma[i-1] : Bars.ClosePrices[i]) + _a4[i];
            
            outJSMA[i] = _jsma[i];
        }
    }
}