Description
Hi
In this indicator, I have tried to combine two indicators Stochastic and Rsi in the simplest way.
This is not the best way, but it works.
For years, CTrader users have been asking the creators of this software to add this feature, but I don't know where the problem is and why they don't do it!
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
{
[Levels(80,20)]
[Indicator(AccessRights = AccessRights.None)]
public class RsiStoch : Indicator
{
[Parameter("Enable Stoch", Group = "Setting", DefaultValue = true)]
public bool Show_Stoch { get; set; }
[Parameter("K Periods", DefaultValue = 9, Group = "Stoch")]
public int kPeriods { get; set; }
[Parameter("K Slowing", DefaultValue = 3, Group = "Stoch")]
public int kSlowing { get; set; }
[Parameter("D Periods", DefaultValue = 3, Group = "Stoch")]
public int dPeriods { get; set; }
[Parameter("MA Type", DefaultValue = MovingAverageType.Simple, Group = "Stoch")]
public MovingAverageType maType { get; set; }
[Parameter("Enable Rsi", Group = "Setting", DefaultValue = true)]
public bool Show_Rsi { get; set; }
[Parameter("Period", DefaultValue = 14, Group = "Rsi")]
public int Rsi_Period { get; set; }
public StochasticOscillator Stoch;
public RelativeStrengthIndex Rsi;
[Output("%K", LineColor = "Yellow")]
public IndicatorDataSeries Stoch_Kline { get; set; }
[Output("%D", LineColor = "Red")]
public IndicatorDataSeries Stoch_Dline { get; set; }
[Output("Rsi", LineColor = "Blue")]
public IndicatorDataSeries Rsi_line { get; set; }
protected override void Initialize()
{
if (Show_Stoch)
{
Stoch = Indicators.StochasticOscillator(kPeriods, kSlowing, dPeriods, maType);
}
if (Show_Rsi)
{
Rsi = Indicators.RelativeStrengthIndex(Bars.ClosePrices, Rsi_Period);
}
}
public override void Calculate(int index)
{
if (Show_Stoch)
{
Stoch_Kline[index] = Stoch.PercentK.Last(0);
Stoch_Dline[index] = Stoch.PercentD.Last(0);
}
if (Show_Rsi)
{
Rsi_line[index] = Rsi.Result.Last(0);
}
}
}
}
AlgoCreators
Joined on 16.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: RsiStoch.algo
- Rating: 5
- Installs: 887
- Modified: 18/05/2023 18:46
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.
VE
I have a similar indicator that shoes as clouds and or lines , it also has MACD but the output is set to "signal +50" to line up with RSI and Stochastic 50 but the scale needs to be set to each chart as needed.
Maybe you have some ideas to make this part automatic ?
I also tried to properly integrate Macd with these two indicators, but I did not get any results