Category Oscilators  Published on 07/02/2023

Andean Oscillator

Description

Andean Oscillator 

The proposed indicator aims to measure the degree of variations of individual up-trends and down-trends in the price, thus allowing to highlight the direction and amplitude of a current trend.


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

namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, AutoRescale = false, AccessRights = AccessRights.None)]
    public class mAndeanOscillator : Indicator
    {
        [Parameter("Periods (14)", DefaultValue = 50)]
        public int inpPeriods { get; set; }

        [Output("Bulls", LineColor = "Green", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries outBulls { get; set; }
        [Output("Bears", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries outBears { get; set; }
        [Output("Signal", LineColor = "FF33C1F3", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outSignal { get; set; }
        
        private double alpha;
        private IndicatorDataSeries _ups, _upp, _dns, _dnp, _bulls, _bears, _max;
        private MovingAverage _signal;

        protected override void Initialize()
        {
            alpha = 2 / (Convert.ToDouble(inpPeriods) + 1);
            _ups = CreateDataSeries();
            _upp = CreateDataSeries();
            _dns = CreateDataSeries();
            _dnp = CreateDataSeries();
            _bulls = CreateDataSeries();
            _bears = CreateDataSeries();
            _max = CreateDataSeries();            
            _signal = Indicators.MovingAverage(_max, inpPeriods, MovingAverageType.Exponential);
        }

        public override void Calculate(int i)
        {
            _ups[i] = i>1 ? Math.Max(Bars.OpenPrices[i], Math.Max(Bars.ClosePrices[i], _ups[i-1] - (_ups[i-1] - Bars.ClosePrices[i]) * alpha)) : Math.Max(Bars.ClosePrices[i], Bars.OpenPrices[i]);
            _upp[i] = i>1 ? Math.Max(Bars.OpenPrices[i] * Bars.OpenPrices[i], Math.Max(Bars.ClosePrices[i] * Bars.ClosePrices[i], _upp[i-1] - (_upp[i-1] - Bars.ClosePrices[i] * Bars.ClosePrices[i]) * alpha)) : Bars.ClosePrices[i] * Bars.ClosePrices[i];
            _dns[i] = i>1 ? Math.Min(Bars.OpenPrices[i], Math.Min(Bars.ClosePrices[i], _dns[i-1] + (Bars.ClosePrices[i] - _dns[i-1]) * alpha)) : Bars.ClosePrices[i];
            _dnp[i] = i>1 ? Math.Min(Bars.OpenPrices[i] * Bars.OpenPrices[i], Math.Min(Bars.ClosePrices[i] * Bars.ClosePrices[i], _dnp[i-1] + (Bars.ClosePrices[i] * Bars.ClosePrices[i] - _dnp[i-1]) * alpha)) : Bars.ClosePrices[i] * Bars.ClosePrices[i];
            _bulls[i] = Math.Sqrt(_dnp[i] - _dns[i] * _dns[i]);
            _bears[i] = Math.Sqrt(_upp[i] - _ups[i] * _ups[i]);
            _max[i] = Math.Max(_bulls[i], _bears[i]);
            
            outBulls[i] = _bulls[i];
            outBears[i] = _bears[i];
            outSignal[i] = _signal.Result[i];
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mAndeanOscillator.algo
  • Rating: 5
  • Installs: 626
Comments
Log in to add a comment.
WE
weelmedia · 1 year ago

Your writing is excellent, so allow me to share a little of myself. One of the best available limitless running games is retro games. Control your ball as you compete in a fast ramp race to see how far you can climb the leaderboard.

SA
safetycasino1 · 1 year ago

When I read an article on this topic, 카지노게임사이트 the first thought was profound and difficult, and I wondered if others could understand..  My site has a discussion board for articles and photos similar to this topic. Could you please visit me when you have time to discuss this topic?