Category Other  Published on 05/06/2023

Slow Adaptive Trend Line indicator

Description

The Slow Adaptive Trend Line (SATL) is formed using the digital filter of the low-frequency FLF-2.

The FLF-2 filter is designed to suppress noise and market cycles with longer periods of oscillation. Both the low-frequency filters, FLF-1 and FLF-2, provide attenuation in the stop band of no less than 40 dB and do not distort the amplitude and phase of the entry discontinuous price series in the pass band (bandwidth).

These properties of the digital filters significantly improve noise suppression compared to a simple moving average, which, in turn, sharply reduces the probability of false signals for buying and selling.

There are no analogues to SATL among widely known technical instruments. It is not a moving average, but rather an adaptive line estimate of a long-term trend.


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

namespace cAlgo
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class mSATL : Indicator
    {
        [Parameter("Data Source (close)", DefaultValue = enumPriceTypes.Close)]
        public enumPriceTypes inpPriceType { get; set; }

        [Output("SATL", LineColor = "Black", PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries outSATL { get; set; }
        
        private IndicatorDataSeries _price, _satl;
       

        protected override void Initialize()
        {
            _price = CreateDataSeries();
            _satl = CreateDataSeries();
        }

        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;
            }
            
            _satl[i] = i>64 ?
               +0.0982862174 * _price[i]
               +0.0975682269 * _price[i-1]
               +0.0961401078 * _price[i-2]
               +0.0940230544 * _price[i-3]
               +0.0912437090 * _price[i-4]
               +0.0878391006 * _price[i-5]
               +0.0838544303 * _price[i-6]
               +0.0793406350 * _price[i-7]
               +0.0743569346 * _price[i-8]
               +0.0689666682 * _price[i-9]
               +0.0632381578 * _price[i-10]
               +0.0572428925 * _price[i-11]
               +0.0510534242 * _price[i-12]
               +0.0447468229 * _price[i-13]
               +0.0383959950 * _price[i-14]
               +0.0320735368 * _price[i-15]
               +0.0258537721 * _price[i-16]
               +0.0198005183 * _price[i-17]
               +0.0139807863 * _price[i-18]
               +0.0084512448 * _price[i-19]
               +0.0032639979 * _price[i-20]
               -0.0015350359 * _price[i-21]
               -0.0059060082 * _price[i-22]
               -0.0098190256 * _price[i-23]
               -0.0132507215 * _price[i-24]
               -0.0161875265 * _price[i-25]
               -0.0186164872 * _price[i-26]
               -0.0205446727 * _price[i-27]
               -0.0219739146 * _price[i-28]
               -0.0229204861 * _price[i-29]
               -0.0234080863 * _price[i-30]
               -0.0234566315 * _price[i-31]
               -0.0231017777 * _price[i-32]
               -0.0223796900 * _price[i-33]
               -0.0213300463 * _price[i-34]
               -0.0199924534 * _price[i-35]
               -0.0184126992 * _price[i-36]
               -0.0166377699 * _price[i-37]
               -0.0147139428 * _price[i-38]
               -0.0126796776 * _price[i-39]
               -0.0105938331 * _price[i-40]
               -0.0084736770 * _price[i-41]
               -0.0063841850 * _price[i-42]
               -0.0043466731 * _price[i-43]
               -0.0023956944 * _price[i-44]
               -0.0005535180 * _price[i-45]
               +0.0011421469 * _price[i-46]
               +0.0026845693 * _price[i-47]
               +0.0040471369 * _price[i-48]
               +0.0052380201 * _price[i-49]
               +0.0062194591 * _price[i-50]
               +0.0070340085 * _price[i-51]
               +0.0076266453 * _price[i-52]
               +0.0080376628 * _price[i-53]
               +0.0083037666 * _price[i-54]
               +0.0083694798 * _price[i-55]
               +0.0082901022 * _price[i-56]
               +0.0080741359 * _price[i-57]
               +0.0077543820 * _price[i-58]
               +0.0073260526 * _price[i-59]
               +0.0068163569 * _price[i-60]
               +0.0062325477 * _price[i-61]
               +0.0056078229 * _price[i-62]
               +0.0049516078 * _price[i-63]
               +0.0161380976 * _price[i-64]
               : _price[i];
               
            outSATL[i] = _satl[i];
        }
    }
     
    public enum enumPriceTypes
    {
        Open,
        Close,
        High,
        Low,
        Median,
        Typical,
        Weighted
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mSATL.algo
  • Rating: 5
  • Installs: 611
  • Modified: 05/06/2023 19:56
Comments
Log in to add a comment.
No comments found.