Bolling bands combined with RSI

Created at 10 Jun 2017, 14:31
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!
HE

heineandersen85

Joined 10.06.2017

Bolling bands combined with RSI
10 Jun 2017, 14:31


Hi,

Can anyone help me with code for indicator that have following:
RSI combined with bollinger.

Looks like this in tradingview, the two of them combined.

RSI standard is (14, close)
Bollinger i want to be able to set it, but standard (20, close) is fine.

 


@heineandersen85
Replies

heineandersen85
11 Jun 2017, 16:33

i found the below code, but what if I want to set some bollingbands settings, in the below code only RSI settings is possible to change when I open it in cTrader.

 

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class Test : Indicator
    {
        [Parameter()]
        public DataSeries Source { get; set; }

        [Parameter(DefaultValue = 14)]
        public int Period { get; set; }

        [Parameter(DefaultValue = 2)]
        public double stdDev { get; set; }

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

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

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

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

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

        BollingerBands bbands;
        RelativeStrengthIndex rsi;


        protected override void Initialize()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, Period);
            bbands = Indicators.BollingerBands(rsi.Result, Period, stdDev, MAType);
        }

        public override void Calculate(int index)
        {
            RSI[index] = rsi.Result[index];
            Bottom[index] = bbands.Bottom[index];
            Top[index] = bbands.Top[index];
            Main[index] = bbands.Main[index];
        }
    }
}


@heineandersen85

Click
11 Jun 2017, 22:44

Try this code :)

 

 

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class Test : Indicator
    {
        [Parameter()]
        public DataSeries Source { get; set; }

        [Parameter(DefaultValue = 14)]
        public int Period { get; set; }

        [Parameter(DefaultValue = 20)]
        public int Period2 { get; set; }

        [Parameter(DefaultValue = 2)]
        public double stdDev { get; set; }

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

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

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

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

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

        BollingerBands bbands;
        RelativeStrengthIndex rsi;


        protected override void Initialize()
        {
            rsi = Indicators.RelativeStrengthIndex(Source, Period);
            bbands = Indicators.BollingerBands(rsi.Result, Period2, stdDev, MAType);
        }

        public override void Calculate(int index)
        {
            RSI[index] = rsi.Result[index];
            Bottom[index] = bbands.Bottom[index];
            Top[index] = bbands.Top[index];
            Main[index] = bbands.Main[index];
        }
    }
}


@Click

Jiri
12 Jun 2017, 00:37 ( Updated at: 21 Dec 2023, 09:20 )

No need to code anything, cTrader is capable of combining multiple indicators.


@Jiri

ClickAlgo
12 Jun 2017, 07:16

great video example Jiri


@ClickAlgo

heineandersen85
12 Jun 2017, 13:54

What a great video and fast response, thanks tmc and click! :)


@heineandersen85