Replies

Dm2025
06 Feb 2016, 01:34

Good news. I have figured it out.

/api/guides/indicators near the bottom of the page I found something on combining two indicators. The following is how you can have multiple indicators in one indicator window.

using cAlgo.API;
using cAlgo.API.Indicators;
 
namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, ScalePrecision = 5)]
    public class Aroon_RSI_DMS : Indicator
    {
        private Aroon aroon ;
        private RelativeStrengthIndex rsi;
        private DirectionalMovementSystem dms;
 
        [Parameter]
        public DataSeries Source { get; set; }
 
        [Parameter(DefaultValue = 14)]
        public int Periods { get; set; }
         
 
        [Output("Aroon Up", Color = Colors.LightSkyBlue)]
        public IndicatorDataSeries AroonUp { get; set; }
 
        [Output("Aroon Down", Color = Colors.Red)]
        public IndicatorDataSeries AroonDn { get; set; }
 
        [Output("Rsi", Color = Colors.Green)]
        public IndicatorDataSeries Rsi { get; set; }
 
        [Output("DI Plus", Color = Colors.DarkGreen)]
        public IndicatorDataSeries DmsDIPlus { get; set; }
 
        [Output("DI Minus", Color = Colors.DarkRed)]
        public IndicatorDataSeries DmsDIMinus { get; set; }
 
        [Output("ADX", Color = Colors.Blue)]
        public IndicatorDataSeries DmsADX { get; set; }
 
 
        protected override void Initialize()
        {
            // Initialize and create nested indicators
            aroon = Indicators.Aroon(Periods);
            rsi = Indicators.RelativeStrengthIndex(Source, Periods);
            dms = Indicators.DirectionalMovementSystem(Periods);
        }
 
 
        public override void Calculate(int index)
        {
            AroonUp[index] = aroon.Up[index];
            AroonDn[index] = aroon.Down[index];
 
            Rsi[index] = rsi.Result[index];
 
            DmsADX[index] = dms.ADX[index];
            DmsDIMinus[index] = dms.DIMinus[index];
            DmsDIPlus[index] = dms.DIPlus[index];
             
        }
 
    }
}

So for the RSI I used this code:

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AutoRescale = true, TimeZone = TimeZones.UTC, ScalePrecision = 0)]
    public class DoubleRsi : Indicator
    {
        private RelativeStrengthIndex rsi;
        private RelativeStrengthIndex rsi2;

        [Parameter()]
        public DataSeries Source { get; set; }

        [Output("Rsi", Color = Colors.Green)]
        public IndicatorDataSeries Rsi { get; set; }

        [Output("Rsi2", Color = Colors.Red)]
        public IndicatorDataSeries Rsi2 { get; set; }

        protected override void Initialize()
        {
            // Initialize and create nested indicators
            rsi = Indicators.RelativeStrengthIndex(Source, 14);
            rsi2 = Indicators.RelativeStrengthIndex(Source, 5);
        }

        public override void Calculate(int index)
        {
            Rsi[index] = rsi.Result[index];
            Rsi2[index] = rsi2.Result[index];
        }

    }
}

And now we have mt4 functionality.


@Dm2025