Bollinger Band indicator on screen

Created at 09 Oct 2022, 14:03
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
EY

eynt

Joined 08.05.2020

Bollinger Band indicator on screen
09 Oct 2022, 14:03


I have a custom indicator which an addition to its use I want it to show a Bollinger Band indicator on screen. How can I do that?

 

Thanks


@eynt
Replies

PanagiotisChar
10 Oct 2022, 09:16

Hi Yuval,

Here is a starting point

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(AccessRights = AccessRights.None, IsOverlay = true)]
    public class NewIndicator : Indicator
    {
        [Output("Main")]
        public IndicatorDataSeries Main { get; set; }

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

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

        BollingerBands _bb;

        protected override void Initialize()
        {
            _bb = Indicators.BollingerBands(Bars.ClosePrices, 20, 2, MovingAverageType.Simple);
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            Main[index] = _bb.Main[index];
            Top[index] = _bb.Top[index];
            Bottom[index] = _bb.Bottom[index];
        }
    }
}

Aieden Technologies

Trade with us

 


@PanagiotisChar

eynt
11 Oct 2022, 00:28

RE:

Thank you

 

Is there a way to set the bands color by code?


@eynt

eynt
12 Oct 2022, 15:06 ( Updated at: 12 Oct 2022, 15:07 )

RE: RE:

Is there a way at least to set the default color value?

Thanks

 


@eynt

PanagiotisChar
13 Oct 2022, 07:42 ( Updated at: 13 Oct 2022, 07:45 )

Hi Yuval,

Is there a way to set the bands color by code?

Unfortunately this is not possible.

Is there a way at least to set the default color value?

Yes see below

[Output("Main", LineColor = "Red")]

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar