Bolling bands combined with RSI
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.
Replies
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
heineandersen85
12 Jun 2017, 13:54
What a great video and fast response, thanks tmc and click! :)
@heineandersen85
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