Polarized Fractal Efficiency indicator free

by mfejza in category Oscilator at 01/02/2023
Description

The Polarized Fractal Efficiency indicator is designed for identifying trend from deriving fast and slow ROC indicator values

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 System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Levels(-100, -50, 0, 50, 100)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mPFE : Indicator
    {
        [Parameter("PeriodFastROC (7)", DefaultValue = 1, MinValue = 1)]
        public int PeriodFastROC { get; set; }
        [Parameter("PeriodSlowROC (9)", DefaultValue = 9, MinValue = 3)]
        public int PeriodSlowROC { get; set; }
        [Parameter("PeriodMA (5)", DefaultValue = 5, MinValue = 1)]
        public int PeriodMA { get; set; }
        [Parameter("PDS (710)", DefaultValue = 10, MinValue = 1)]
        public int PDS { get; set; }
        [Parameter("MA Type", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType MAType { get; set; }

        [Output("olarized Fractal Efficiency", LineColor = "Black", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outPFE { get; set; }


        private IndicatorDataSeries _raw;
        private IndicatorDataSeries _pfe;
        private MovingAverage _pfema;
        double slow, fast, x, y, z;


        protected override void Initialize()
        {
            _raw = CreateDataSeries();
            _pfe = CreateDataSeries();
            _pfema = Indicators.MovingAverage(_raw, PeriodMA, MAType);
        }

        public override void Calculate(int i)
        {
            slow = (Bars.ClosePrices[i + PeriodSlowROC] != 0 ? 100.0 * (Bars.ClosePrices[i] / Bars.ClosePrices[i + PeriodSlowROC] - 1) : 0);
            fast = (Bars.ClosePrices[i + PeriodFastROC] != 0 ? 100.0 * (Bars.ClosePrices[i] / Bars.ClosePrices[i + PeriodFastROC] - 1) : 0);
            x = Math.Sqrt(slow * slow + 100.0);
            y = Math.Sqrt(fast * fast + 1.0) + PDS;
            z = x / (y != 0 ? y : 1);
            _raw[i] = (Bars.ClosePrices[i] > Bars.ClosePrices[i + PeriodSlowROC] ? 100.0 * z : -100.0 * z);

            outPFE[i] = _pfema.Result[i];
        }
    }
}
Comments
0