Category Volatility  Published on 06/06/2023

Fast/Slow Adaptive Trend Line indicator

Description

This indicator shows the average value of the FATL and SATL indicators, which are averaged within the fast and slow zones of the ATL.

Additionally, the shadow represents the zone between the values of the FATL and SATL indicator values.

You can find the FALT indicator here: ctrader.com/algos/indicators/show/3453

You can find the SALT indicator here: ctrader.com/algos/indicators/show/3454


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

namespace cAlgo
{
    [Cloud("FATL", "SATL", FirstColor = "Magenta", SecondColor = "Magenta", Opacity = 0.1)]  
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class mFATL : Indicator
    {
        [Parameter("Data Source (close)", DefaultValue = enumPriceTypes.Close)]
        public enumPriceTypes inpPriceType { get; set; }
        [Parameter("Show Zones (yes)", DefaultValue = true)]
        public bool inpShowZones { get; set; }

        [Output("FSATL", LineColor = "Black", PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries outFSATL { get; set; }
        [Output("FATL", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries outFATL { get; set; }
        [Output("SATL", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries outSATL { get; set; }
        
        private IndicatorDataSeries _price, _fatl, _satl, _fsalt;
       

        protected override void Initialize()
        {
            _price = CreateDataSeries();
            _fatl = CreateDataSeries();
            _satl = CreateDataSeries();
            _fsalt = 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;
            }
            
            _fatl[i] = i>38 ?
                 0.4360409450 * _price[i]
               + 0.3658689069 * _price[i-1]
               + 0.2460452079 * _price[i-2]
               + 0.1104506886 * _price[i-3]
               - 0.0054034585 * _price[i-4]
               - 0.0760367731 * _price[i-5]
               - 0.0933058722 * _price[i-6]
               - 0.0670110374 * _price[i-7]
               - 0.0190795053 * _price[i-8]
               + 0.0259609206 * _price[i-9]
               + 0.0502044896 * _price[i-10]
               + 0.0477818607 * _price[i-11]
               + 0.0249252327 * _price[i-12]
               - 0.0047706151 * _price[i-13]
               - 0.0272432537 * _price[i-14]
               - 0.0338917071 * _price[i-15]
               - 0.0244141482 * _price[i-16]
               - 0.0055774838 * _price[i-17]
               + 0.0128149838 * _price[i-18]
               + 0.0226522218 * _price[i-19]
               + 0.0208778257 * _price[i-20]
               + 0.0100299086 * _price[i-21]
               - 0.0036771622 * _price[i-22]
               - 0.0136744850 * _price[i-23]
               - 0.0160483392 * _price[i-24]
               - 0.0108597376 * _price[i-25]
               - 0.0016060704 * _price[i-26]
               + 0.0069480557 * _price[i-27]
               + 0.0110573605 * _price[i-28]
               + 0.0095711419 * _price[i-29]
               + 0.0040444064 * _price[i-30]
               - 0.0023824623 * _price[i-31]
               - 0.0067093714 * _price[i-32]
               - 0.0072003400 * _price[i-33]
               - 0.0047717710 * _price[i-34]
               + 0.0005541115 * _price[i-35]
               + 0.0007860160 * _price[i-36]
               + 0.0130129076 * _price[i-37]
               + 0.0040364019 * _price[i-38]
               : _price[i];
               
            _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];
               
            _fsalt[i] = (_fatl[i] + _satl[i]) /2;
               
            outFSATL[i] = _fsalt[i];
            outFATL[i] = inpShowZones == true ? _fatl[i] : _fsalt[i];
            outSATL[i] = inpShowZones == true ? _satl[i] : _fsalt[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: mFSATL.algo
  • Rating: 5
  • Installs: 667
  • Modified: 06/06/2023 07:23
Comments
Log in to add a comment.
No comments found.