Description
This is an RSI with a moving average of it for Trend direction and makes it easier to spot divergences.
Also you can see RSI bouncing on/off the MA often.
OB/OS areas are colorized
Fully customizable
Changelog
15.03.2020 - Added ability to smooth RSI
If you like my work, feel free to spend me a Corona Beer :-)
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo.Indicators
{
[Cloud("OB1 Level", "OB2 Level")]
[Cloud("OS1 Level", "OS2 Level")]
[Cloud("RSI", "MA")]
[Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
public class RSI_Cloud : Indicator
{
/////////////////////////////////////////////////////// PARAMETERS
[Parameter("Period", Group = "RSI", DefaultValue = 14)]
public int rsiPeriod { get; set; }
[Parameter("Smooth", Group = "RSI Smoothing", DefaultValue = false)]
public bool Smooth { get; set; }
[Parameter("Smooth Period", Group = "RSI Smoothing", DefaultValue = 4)]
public int SmoothPeriod { get; set; }
[Parameter("Smooth Type", Group = "RSI Smoothing", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType SmoothType { get; set; }
[Parameter("OS1 Level", Group = "Levels", DefaultValue = 30)]
public int OS1_value { get; set; }
[Parameter("OS2 Level", Group = "Levels", DefaultValue = 20)]
public int OS2_value { get; set; }
[Parameter("OB1 Level", Group = "Levels", DefaultValue = 70)]
public int OB1_value { get; set; }
[Parameter("OB2 Level", Group = "Levels", DefaultValue = 80)]
public int OB2_value { get; set; }
[Parameter("Show", Group = "MA of RSI", DefaultValue = true)]
public bool maShow { get; set; }
[Parameter("Type", Group = "MA of RSI", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType MAType { get; set; }
[Parameter("Period", Group = "MA of RSI", DefaultValue = 20)]
public int maPeriod { get; set; }
///////////////////////////////////////////////////////
private MovingAverage _ma;
private RelativeStrengthIndex _rsi;
private MovingAverage _rsismooth;
/////////////////////////////////////////////////////// LEVELS
[Output("OB1 Level", LineColor = "DarkRed", LineStyle = LineStyle.Dots, Thickness = 1)]
public IndicatorDataSeries OB1_level { get; set; }
[Output("OB2 Level", LineColor = "DarkRed", LineStyle = LineStyle.Dots, Thickness = 1)]
public IndicatorDataSeries OB2_level { get; set; }
// ---------------
[Output("OS1 Level", LineColor = "DarkGreen", LineStyle = LineStyle.Dots, Thickness = 1)]
public IndicatorDataSeries OS1_level { get; set; }
[Output("OS2 Level", LineColor = "DarkGreen", LineStyle = LineStyle.Dots, Thickness = 1)]
public IndicatorDataSeries OS2_level { get; set; }
// ---------------
[Output("Mid Level", LineColor = "DimGray", LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries midlevel { get; set; }
/////////////////////////////////////////////////////// OUTPUTS
[Output("RSI", LineColor = "Green", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries RSIResult { get; set; }
[Output("MA", LineColor = "Red")]
public IndicatorDataSeries MAofRSI { get; set; }
/////////////////////////////////////////////////////// INITIALIZE
protected override void Initialize()
{
DataSeries _ds = Bars.TypicalPrices;
_rsi = Indicators.RelativeStrengthIndex(_ds, rsiPeriod);
_rsismooth = Indicators.MovingAverage(_rsi.Result, SmoothPeriod, SmoothType);
_ma = Indicators.MovingAverage(_rsi.Result, maPeriod, MAType);
}
/////////////////////////////////////////////////////// CALCULATE
public override void Calculate(int index)
{
// Levels
OS1_level[index] = OS1_value;
OS2_level[index] = OS2_value;
OB1_level[index] = OB1_value;
OB2_level[index] = OB2_value;
midlevel[index] = 50;
if (Smooth)
RSIResult[index] = _rsismooth.Result[index];
else
RSIResult[index] = _rsi.Result[index];
if (maShow)
MAofRSI[index] = _ma.Result[index];
}
}
}
DO
DontMatter
Joined on 15.11.2019
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: RSI_Cloud.algo
- Rating: 5
- Installs: 3700
- Modified: 13/10/2021 09:54
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.