Category Trend  Published on 11/10/2022

Period Extreme

Description

The 'Period Extreme' custom indicator identifies the ongoing price pressure within the current price impulse. 

Following the previous 'period extreme' serves as a reference point for determining the point of no return, effectively used as a level for swing breaks.


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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mExtremePeriod : Indicator
    {
        [Parameter("Periods (1)",  DefaultValue = 1, MinValue = 1)]
        public int inpPeriods { get; set; }

        [Output("OpenLong trigger", LineColor = "Orange", PlotType = PlotType.Points, Thickness = 5)]
        public IndicatorDataSeries outExtremeLong { get; set; }
        [Output("OpenShort trigger", LineColor = "Magenta", PlotType = PlotType.Points, Thickness = 5)]
        public IndicatorDataSeries outExtremeShort { get; set; }
        
        private IndicatorDataSeries _hh, _ll, _long, _short;
        

        protected override void Initialize()
        {
            _hh = CreateDataSeries();
            _ll = CreateDataSeries();
            _long = CreateDataSeries();
            _short = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            _hh[i] = i>inpPeriods+1 ? Bars.HighPrices.Maximum(inpPeriods+1) : Bars.HighPrices[i];
            _ll[i] = i>inpPeriods+1 ? Bars.LowPrices.Minimum(inpPeriods+1) : Bars.LowPrices[i];            
            _long[i] = i>1 && Bars.ClosePrices[i] > _hh[i-1] ? _hh[i-1] : double.NaN;
            _short[i] = i>1 && Bars.ClosePrices[i] < _ll[i-1] ? _ll[i-1] : double.NaN;

            outExtremeLong[i] = _long[i];
            outExtremeShort[i] = _short[i];
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mExtremePeriod.algo
  • Rating: 5
  • Installs: 242
  • Modified: 20/11/2023 11:42
Comments
Log in to add a comment.
No comments found.