Category Trend  Published on 21/10/2022

Awesome Oscillator

Description

This is a Simple Awesome Oscillator with multiple Colors for a better visualization of the Histogram Trend.

 

Grupo CTrader em Portugues -->>  https://t.me/ComunidadeCtrader

Para los que quieran participar de un Grupo CTrader en Español poder compartir estrategias, indicadores e mucho más, aquí abajo les dejo el link.

Grupo CTrader en Español -->> https://t.me/ComunidadCtrader

 

 



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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class AwesomeOscillator : Indicator
    {
        [Parameter(DefaultValue = 5)]
        public int periodFast { get; set; }

        [Parameter(DefaultValue = 34)]
        public int periodSlow { get; set; }

        [Parameter("Verbose", DefaultValue = true)]
        public bool OnVerbose { get; set; }

        [Output("Strong Bullish", PlotType = PlotType.Histogram, LineColor = "ForestGreen", Thickness = 4)]
        public IndicatorDataSeries StrongBullish { get; set; }

        [Output("Weak Bullish", PlotType = PlotType.Histogram, LineColor = "LawnGreen", Thickness = 4)]
        public IndicatorDataSeries WeakBullish { get; set; }

        [Output("Strong Bearish", PlotType = PlotType.Histogram, LineColor = "Red", Thickness = 4)]
        public IndicatorDataSeries StrongBearish { get; set; }

        [Output("Weak Bearish", PlotType = PlotType.Histogram, LineColor = "DarkSalmon", Thickness = 4)]
        public IndicatorDataSeries WeakBearish { get; set; }

        private SimpleMovingAverage smaSlow;
        private SimpleMovingAverage smaFast;
        private IndicatorDataSeries medianprice;

        protected override void Initialize()
        {
            medianprice = CreateDataSeries();
            smaSlow = Indicators.SimpleMovingAverage(medianprice, periodSlow);
            smaFast = Indicators.SimpleMovingAverage(medianprice, periodFast);
        }

        public override void Calculate(int index)
        {
            medianprice[index] = (Bars.HighPrices[index] + Bars.LowPrices[index]) / 2;
            double previousAO = smaFast.Result[index - 1] - smaSlow.Result[index - 1];
            double currentAO = smaFast.Result[index] - smaSlow.Result[index];

            if (currentAO > 0.0)
            {
                if (currentAO >= previousAO)
                {
                    StrongBullish[index] = smaFast.Result[index] - smaSlow.Result[index];
                }
                else
                {
                    WeakBullish[index] = smaFast.Result[index] - smaSlow.Result[index];
                }
            }
            else if (currentAO < 0.0)
            {
                if (currentAO <= previousAO)
                {
                    StrongBearish[index] = smaFast.Result[index] - smaSlow.Result[index];
                }
                else
                {
                    WeakBearish[index] = smaFast.Result[index] - smaSlow.Result[index];
                }

            }
        }
    }
}



TraderExperto's avatar
TraderExperto

Joined on 07.06.2019

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