Category Oscilators  Published on 18/05/2023

Bulls Bears Impulse

Description

Indicator Bulls Bears Impulse displays in a separate window a pulse graph showing the market switches from bullish to bearish, and vice versa.


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

namespace cAlgo
{
    [Levels(0)]
    [Cloud("Bulls Impulse", "Bears Impulse", FirstColor = "Green", SecondColor = "Red", Opacity = 0.1)] 
    [Indicator(IsOverlay = false,  AccessRights = AccessRights.None)]
    public class mBullsBearsImpulse : Indicator
    {
        [Parameter("Periods (13)", DefaultValue = 13)]
        public int inpPeriods { get; set; }

        [Output("Bulls Impulse", LineColor = "Green", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outBullsImpulse { get; set; }
        [Output("Bears Impulse", LineColor = "Red", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outBearsImpulse { get; set; }
        
        private MovingAverage _pricesmooth;
        private IndicatorDataSeries _bulls, _bears;
        

        protected override void Initialize()
        {
            _pricesmooth = Indicators.MovingAverage(Bars.ClosePrices, inpPeriods, MovingAverageType.Exponential);
            _bulls = CreateDataSeries();
            _bears = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            _bulls[i] = Bars.HighPrices[i] - _pricesmooth.Result[i];
            _bears[i] = Bars.LowPrices[i] - _pricesmooth.Result[i];
            
            outBullsImpulse[i] = _bulls[i] + _bears[i] > 0 ? +1 : -1;
            outBearsImpulse[i] = _bulls[i] + _bears[i] < 0 ? +1 : -1;
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

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