Description
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC)]
public class AdxR : Indicator
{
[Parameter("%K periods 1", DefaultValue = 20)]
public int inpKPeriods1 { get; set; }
[Parameter("%K Slowing 1", DefaultValue = 7)]
public int inpKSlowing1 { get; set; }
[Parameter("%D periods 1", DefaultValue = 20)]
public int inpDPeriods1 { get; set; }
[Parameter("MA type 1", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType inpMAType1 { get; set; }
[Parameter("%K periods 2", DefaultValue = 9)]
public int inpKPeriods2 { get; set; }
[Parameter("%K Slowing 2", DefaultValue = 3)]
public int inpKSlowing2 { get; set; }
[Parameter("%D periods 2", DefaultValue = 9)]
public int inpDPeriods2 { get; set; }
[Parameter("MA type 2", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType inpMAType2 { get; set; }
[Output("SlowPercenD", Color = Colors.Orange, LineStyle = LineStyle.Lines)]
public IndicatorDataSeries SlowD { get; set; }
[Output("SlowPercentK", Color = Colors.Orange, LineStyle = LineStyle.LinesDots)]
public IndicatorDataSeries SlowK { get; set; }
[Output("FastPercentD", Color = Colors.Blue, LineStyle = LineStyle.Lines)]
public IndicatorDataSeries FastD { get; set; }
[Output("FastPercentK", Color = Colors.Blue, LineStyle = LineStyle.LinesDots)]
public IndicatorDataSeries FastK { get; set; }
private StochasticOscillator _stochasticslow;
private StochasticOscillator _stochasticfast;
protected override void Initialize()
{
_stochasticslow = Indicators.StochasticOscillator(inpKPeriods1, inpKSlowing1, inpDPeriods1, inpMAType1);
_stochasticfast = Indicators.StochasticOscillator(inpKPeriods2, inpKSlowing2, inpDPeriods2, inpMAType2);
}
public override void Calculate(int index)
{
SlowD[index] = _stochasticslow.PercentD[index];
SlowK[index] = _stochasticslow.PercentK[index];
FastD[index] = _stochasticfast.PercentD[index];
FastK[index] = _stochasticfast.PercentK[index];
}
}
}
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC)]
public class AdxR : Indicator
{
[Parameter("%K periods 1", DefaultValue = 20)]
public int inpKPeriods1 { get; set; }
[Parameter("%K Slowing 1", DefaultValue = 7)]
public int inpKSlowing1 { get; set; }
[Parameter("%D periods 1", DefaultValue = 20)]
public int inpDPeriods1 { get; set; }
[Parameter("MA type 1", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType inpMAType1 { get; set; }
[Parameter("%K periods 2", DefaultValue = 9)]
public int inpKPeriods2 { get; set; }
[Parameter("%K Slowing 2", DefaultValue = 3)]
public int inpKSlowing2 { get; set; }
[Parameter("%D periods 2", DefaultValue = 9)]
public int inpDPeriods2 { get; set; }
[Parameter("MA type 2", DefaultValue = MovingAverageType.Simple)]
public MovingAverageType inpMAType2 { get; set; }
[Output("SlowPercenD", Color = Colors.Orange, LineStyle = LineStyle.Lines)]
public IndicatorDataSeries SlowD { get; set; }
[Output("SlowPercentK", Color = Colors.Orange, LineStyle = LineStyle.LinesDots)]
public IndicatorDataSeries SlowK { get; set; }
[Output("FastPercentD", Color = Colors.Blue, LineStyle = LineStyle.Lines)]
public IndicatorDataSeries FastD { get; set; }
[Output("FastPercentK", Color = Colors.Blue, LineStyle = LineStyle.LinesDots)]
public IndicatorDataSeries FastK { get; set; }
private StochasticOscillator _stochasticslow;
private StochasticOscillator _stochasticfast;
protected override void Initialize()
{
_stochasticslow = Indicators.StochasticOscillator(inpKPeriods1, inpKSlowing1, inpDPeriods1, inpMAType1);
_stochasticfast = Indicators.StochasticOscillator(inpKPeriods2, inpKSlowing2, inpDPeriods2, inpMAType2);
}
public override void Calculate(int index)
{
SlowD[index] = _stochasticslow.PercentD[index];
SlowK[index] = _stochasticslow.PercentK[index];
FastD[index] = _stochasticfast.PercentD[index];
FastK[index] = _stochasticfast.PercentK[index];
}
}
}
viktan
Joined on 25.11.2015
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: 2Stochastic.algo
- Rating: 0
- Installs: 3350
- Modified: 13/10/2021 09:55
Hi what would I have to change in the code to make this indicator calculate from another indicator on the chart and not price?
Cheers
J