Balance Of Power (BOP) free

by Spotware in category Oscilator at 07/09/2021
Description

This is the Balance of Power (BOP) oscillator indicator for cTrader.

Github: spotware/Balance-of-Power: This Balance of Power (BOP) indicator for cTrader (github.com)

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
// -------------------------------------------------------------------------------------------------
//
//    This is the Balance Of Power custom indicator for cTrader based on Automate API.
//
// -------------------------------------------------------------------------------------------------

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class BalanceofPower : Indicator
    {
        private IndicatorDataSeries _bop;
        private MovingAverage _ma;

        [Parameter("Periods", DefaultValue = 14)]
        public int Periods { get; set; }

        [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MaType { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        protected override void Initialize()
        {
            _bop = CreateDataSeries();
            _ma = Indicators.MovingAverage(_bop, Periods, MaType);
        }

        public override void Calculate(int index)
        {
            var bar = Bars[index];

            _bop[index] = (bar.Close - bar.Open) / (bar.High - bar.Low);
            Result[index] = _ma.Result[index];
        }
    }
}
Comments
0