Category Oscilators  Published on 01/02/2023

Open Oscillator indicator

Description

Open Oscillator indicator calculates Open price change dynamics for a specified period of time, with minimum and maximum Open prices for the range, relative to the current values, as well as two exponential smooth components.


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

namespace cAlgo
{
    [Levels(0.5)]
    [Indicator(AccessRights = AccessRights.None)]
    public class mOPENosc : Indicator
    {
        [Parameter("Main Periods (20)", DefaultValue = 20)]
        public int inpMainPeriods { get; set; }
        [Parameter("Smooth Periods (10)", DefaultValue = 10)]
        public int inpSmoothPeriods { get; set; }

        [Output("High Delta", LineColor = "Green", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outHigh { get; set; }
        [Output("Low Delta", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outLow { get; set; }
        [Output("High Delta Smooth", LineColor = "Green", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries outHighSmooth { get; set; }
        [Output("Low Delta Smooth", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries outLowSmooth { get; set; }
        
        private IndicatorDataSeries _ohigh, _olow;
        private MovingAverage _mah, _mal;
        

        protected override void Initialize()
        {
            _ohigh = CreateDataSeries();
            _olow = CreateDataSeries();
            _mah = Indicators.MovingAverage(_ohigh, inpSmoothPeriods, MovingAverageType.Exponential);
            _mal = Indicators.MovingAverage(_olow, inpSmoothPeriods, MovingAverageType.Exponential);
        }

        public override void Calculate(int i)
        {
            _ohigh[i] = i>inpMainPeriods ? Bars.OpenPrices[i] - Bars.OpenPrices.Maximum(inpMainPeriods) : Bars.ClosePrices[i] - Bars.TypicalPrices[i];
            _olow[i] = i>inpMainPeriods ? Bars.OpenPrices.Minimum(inpMainPeriods) -Bars.OpenPrices[i] : Bars.TypicalPrices[i] - Bars.ClosePrices[i];
      
            outHigh[i] = _ohigh[i];
            outLow[i] = _olow[i];
            outHighSmooth[i] = _mah.Result[i];
            outLowSmooth[i] = _mal.Result[i];
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mOPENosc.algo
  • Rating: 5
  • Installs: 426
Comments
Log in to add a comment.
No comments found.