Is this a Repainting or a Non-Repainting Indicator?

Created at 14 Apr 2019, 18:28
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!
MI

micderaj

Joined 14.04.2019

Is this a Repainting or a Non-Repainting Indicator?
14 Apr 2019, 18:28


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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class BollingerBandsJay : Indicator
    {
        private MovingAverage _movingAverage;
        private StandardDeviation _standardDeviationUpper;
        private StandardDeviation _standardDeviationLower;

        [Parameter("Source MA")]
        public DataSeries Source { get; set; }

        [Parameter("Source Upper")]
        public DataSeries SourceUpper { get; set; }

        [Parameter("Source Lower")]
        public DataSeries SourceLower { get; set; }

        [Parameter("Periods MA", DefaultValue = 20, MinValue = 1)]
        public int Periods { get; set; }

        [Parameter("Periods Upper", DefaultValue = 20, MinValue = 1)]
        public int PeriodsUpper { get; set; }

        [Parameter("Periods Lower", DefaultValue = 20, MinValue = 1)]
        public int PeriodsLower { get; set; }

        [Parameter("Standard Deviation Upper", DefaultValue = 2.0, MaxValue = 10, MinValue = 0.0001)]
        public double StandardDeviationsUpper { get; set; }

        [Parameter("Standard Deviation Lower", DefaultValue = 2.0, MaxValue = 10, MinValue = 0.0001)]
        public double StandardDeviationsLower { get; set; }

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

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

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

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

        protected override void Initialize()
        {
            this._movingAverage = this.Indicators.MovingAverage(this.Source, this.Periods, this.MAType);
            this._standardDeviationUpper = this.Indicators.StandardDeviation(this.SourceUpper, this.PeriodsUpper, this.MAType);
            this._standardDeviationLower = this.Indicators.StandardDeviation(this.SourceLower, this.PeriodsLower, this.MAType);
        }

        public override void Calculate(int index)
        {
            double numUpper = this._standardDeviationUpper.Result[index] * this.StandardDeviationsUpper;
            double numLower = this._standardDeviationLower.Result[index] * this.StandardDeviationsLower;
            this.Main[index] = this._movingAverage.Result[index];
            this.Bottom[index] = this._movingAverage.Result[index] - numLower;
            this.Top[index] = this._movingAverage.Result[index] + numUpper;
        }
    }
}

Hi guys,

I just want to confirm if this is a repainting or a non-repainting indicator? Any input would be greatly appreciated. 

Thanks. 

 


@micderaj
Replies

PanagiotisCharalampous
14 Apr 2019, 20:20

Hi micderaj,

Seems like a non repainting to me.

Best Regards,

Panagiotis


@PanagiotisCharalampous

micderaj
14 Apr 2019, 21:28

Hi Panagiotis,

Thank you for the clarification. I appreciate your prompt response, very helpful! 


@micderaj

firemyst
26 Sep 2019, 03:57

RE:

Panagiotis Charalampous said:

Hi micderaj,

Seems like a non repainting to me.

Best Regards,

Panagiotis

@Panagiotis: can you clarify a bit more why you think it's non-repainting?

Since the "Source" is a parameter, this indicator may or may not repaint depending on whether the source is the "Open" price, "Close" price, or something else.

If it's "Open", the indicator won't repaint as the data won't change until the open of the next bar; if any of the sources are something other than "Open", then the indicator will repaint because the current bar is constantly updating the Low, High and Close values with new values.

It might not be updating all past values, but it will constantly be updating current values.

To me, that is repainting.


@firemyst

PanagiotisCharalampous
26 Sep 2019, 08:28

Hi FireMyst,

A repainting indicator is an indicator which updates past values. Almost all indicators update current values, even a simple moving average.

Best Regards,

Panagiotis


@PanagiotisCharalampous