Category Trend  Published on 21/03/2024

SMMA - Smoothed Moving Average

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

This indicator is commonly used to confirm market trends and generate buy/sell signals. 

The main advantage of a smoothed moving average is that it removes short-term fluctuations, and allows us to view the price trends much easier, which is why they are widely used in trending markets.

Definitions

The Smoothed Moving Average (SMMA) is a combination of an SMA and an EMA. It gives the recent prices an equal weighting as the historic prices as it takes all available price data into account.

Calculations

SMMA0 = SMA

SMMAn = (SMMAn-1 * (Length - 1) + Source) / Length

where SMA = Simple Moving Average, SMMA = Smoothed Moving Average

           SMMA0 = First SMMA, SMMAn = Current SMMA, SMMAn-1 = Previous SMMA

Parameters

  • Source - Data Source, e.g. Close, High …
  • Length - Smoothing Period

Outputs

  • SMMA - Smoothed Moving Average line

Chartshot

 

From https://www.chartmill.com/documentation/technical-analysis/indicators/217-The-Smoothed-Moving-Average-SMMA




SO
soskrr

Joined on 20.08.2023

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: SMMA.algo
  • Rating: 0
  • Installs: 719
  • Modified: 21/03/2024 00:42
Comments
Log in to add a comment.
mfejza's avatar
mfejza · 8 months ago

To whom it may concern

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mSMMA : Indicator
    {
        [Parameter("Period (10)", DefaultValue = 10, MinValue = 2)]
        public int inpPeriod { get; set; }
        [Parameter("Data Source (close)", DefaultValue = enumPriceTypes.Close)]
        public enumPriceTypes inpPriceType { get; set; }

        [Output("SMMA", LineColor = "Black", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outSMMA { get; set; }

        private IndicatorDataSeries _price, _smma;
        private MovingAverage _pricesmooth;


        protected override void Initialize()
        {
            _price = CreateDataSeries();
            _smma = CreateDataSeries();
            _pricesmooth = Indicators.MovingAverage(_price, inpPeriod, MovingAverageType.Simple);
        }

        public override void Calculate(int i)
        {
            switch (inpPriceType)
            {
                case enumPriceTypes.Open:
                    _price[i] = Bars.OpenPrices[i];
                    break;
                case enumPriceTypes.Close:
                    _price[i] = Bars.ClosePrices[i];
                    break;
                case enumPriceTypes.High:
                    _price[i] = Bars.HighPrices[i];
                    break;
                case enumPriceTypes.Low:
                    _price[i] = Bars.LowPrices[i];
                    break;
                case enumPriceTypes.Median:
                    _price[i] = Bars.MedianPrices[i];
                    break;
                case enumPriceTypes.Typical:
                    _price[i] = Bars.TypicalPrices[i];
                    break;
                case enumPriceTypes.Weighted:
                    _price[i] = Bars.WeightedPrices[i];
                    break;
                default:
                    _price[i] = Bars.ClosePrices[i];
                    break;
            }
            _smma[i] = (((i>1 ? _smma[i-1] : _price[i]) * (inpPeriod - 1)) + _price[i]) / inpPeriod;
            
            outSMMA[i] = _smma[i];
        }
    }

    public enum enumPriceTypes
    {
        Open,
        Close,
        High,
        Low,
        Median,
        Typical,
        Weighted
    }
}