Plotting Multiple Indicators in single window

Created at 07 Oct 2016, 01:50
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
HI

hitechee

Joined 23.02.2016

Plotting Multiple Indicators in single window
07 Oct 2016, 01:50


Hi All,   I need help from someone to plot the below mentioned indicators to combine in one single indicator window. I would appreciate your kind help.

These are the four indicators namely:- Aroonhorn, Fisher Histogram, Candlesticks Tendency and Volume Oscillator Histogram. Also to  overlay TSMA - 100 & 200 and also TMA - 50. I want the  variable indicator specification window, so that I can  change  the specs as per the required        accuracy.

Is it possible to overly all these indicators be  over the price chart if required.  


Thanks in advance  




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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class AroonHorn : Indicator
    {
        [Parameter(DefaultValue = 10)]
        public int Period { get; set; }

        [Parameter(DefaultValue = 25)]
        public int Filter { get; set; }

        [Output("AroonOSCup", Color = Colors.Blue, IsHistogram = true)]
        public IndicatorDataSeries aroonoscup { get; set; }

        [Output("AroonOSCdown", Color = Colors.Red, IsHistogram = true)]
        public IndicatorDataSeries aroonoscdown { get; set; }

        [Output("AroonOSCGray", Color = Colors.Gray, IsHistogram = true)]
        public IndicatorDataSeries aroonoscgray { get; set; }

        [Output("AroonOSC", Color = Colors.Turquoise)]
        public IndicatorDataSeries aroonosc { get; set; }

        private Aroon aroonhorn;

        protected override void Initialize()
        {
            aroonhorn = Indicators.Aroon(Period);
        }

        public override void Calculate(int index)
        {
            double commander = 10 * (aroonhorn.Up[index] - aroonhorn.Down[index]) / Period;
            if ((commander >= 0) && (commander > Filter))
            {
                aroonoscup[index] = commander;
            }
            if ((commander < 0) && (commander < (-1) * Filter))
            {
                aroonoscdown[index] = commander;
            }
            if ((commander >= (-1) * Filter) && (commander <= Filter))
            {
                aroonoscgray[index] = commander;
            }
            aroonosc[index] = commander;
        }
    }
}

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator("Fisher")]
    public class Fisher : Indicator
    {
        private IndicatorDataSeries _value1;
        private IndicatorDataSeries _buffer0;
        private IndicatorDataSeries _fisher1;

        [Parameter("Period", DefaultValue = 10)]
        public int Period { get; set; }

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

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


        protected override void Initialize()
        {
            _fisher1 = CreateDataSeries();
            _value1 = CreateDataSeries();
            _buffer0 = CreateDataSeries();
        }

        public override void Calculate(int index)
        {
            if (index < Period)
            {
                _value1[index] = 0;
                _fisher1[index] = 0;

                return;
            }

            double maxH = MarketSeries.High.Maximum(Period);
            double minL = MarketSeries.Low.Minimum(Period);

            double price = (MarketSeries.High[index] + MarketSeries.Low[index]) / 2;

            double value = 0.33 * 2 * ((price - minL) / (maxH - minL) - 0.5) + 0.67 * _value1[index - 1];
            value = Math.Min(Math.Max(value, -0.999), 0.999);

            _buffer0[index] = 0.5 * Math.Log((1 + value) / (1 - value)) + 0.5 * _fisher1[index - 1];

            _value1[index] = value;
            _fisher1[index] = _buffer0[index];

            bool up = _buffer0[index] > 0;

            if (!up)
            {
                Buffer2[index] = _buffer0[index];
                Buffer1[index] = 0.0;
            }
            else
            {
                Buffer1[index] = _buffer0[index];
                Buffer2[index] = 0.0;
            }
        }
    }
}

using System;
using cAlgo.API;
using cAlgo.API.Internals;

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

namespace cAlgo
{

    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CandlestickTendency : Indicator
    {

        [Parameter()]
        public TimeFrame HighOrderTimeFrame { get; set; }

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

        [Output("Histogram", PlotType = PlotType.Histogram, Color = Colors.DarkGreen)]
        public IndicatorDataSeries Histogram { get; set; }

        [Output("High Order Line", PlotType = PlotType.Line, Color = Colors.Red)]
        public IndicatorDataSeries HighOrderLine { get; set; }

        int index1, index2;
        MarketSeries series2;
        double value1, value2;

        protected override void Initialize()
        {

            value1 = value2 = 0;
            series2 = MarketData.GetSeries(HighOrderTimeFrame);
        }

        public bool trend1IsRising
        {
            get { return (MarketSeries.Close[index1] > MarketSeries.Open[index1 - 1]); }
        }
        public bool trend1IsFalling
        {
            get { return (MarketSeries.Close[index1] < MarketSeries.Open[index1 - 1]); }
        }
        public bool trend2IsRising
        {
            get { return (series2.Close[index2] > series2.Open[index2 - 1]); }
        }
        public bool trend2IsFalling
        {
            get { return (series2.Close[index2] < series2.Open[index2 - 1]); }
        }

        public override void Calculate(int index)
        {

            index1 = index;
            index2 = series2.OpenTime.GetIndexByExactTime(MarketSeries.OpenTime[index1]);

            if (trend1IsFalling)
                value1 = -1;

            if (trend1IsRising)
                value1 = 1;

            if (trend2IsFalling)
                value2 = -2;

            if (trend2IsRising)
                value2 = 2;

            Line[index] = value2;
            Histogram[index] = value2;
            HighOrderLine[index] = value2;

        }
    }
}

using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class VolumeOscilatorHistogram : Indicator
    {
        private VolumeOscillator _volumeOscillator;
        private double currentVolume;
        private double preVolume;
        private double pre2Volume;

        [Parameter("Short Term", DefaultValue = 5)]
        public int ShortTerm { get; set; }
        [Parameter("Long Term", DefaultValue = 30)]
        public int LongTerm { get; set; }
        [Output("Volume Oscilator", Color = Colors.DodgerBlue, Thickness = 2)]
        public IndicatorDataSeries Result { get; set; }
        [Output("Plus", Color = Colors.DodgerBlue, PlotType = PlotType.Histogram, Thickness = 5)]
        public IndicatorDataSeries Plus { get; set; }
        [Output("Minus", Color = Colors.Gray, PlotType = PlotType.Histogram, Thickness = 5)]
        public IndicatorDataSeries Minus { get; set; }
        protected override void Initialize()
        {
            _volumeOscillator = Indicators.VolumeOscillator(ShortTerm, LongTerm);
        }
        public override void Calculate(int index)
        {
            // Display Result of Indicator
            Result[index] = _volumeOscillator.Result[index];
            currentVolume = _volumeOscillator.Result[index];
            preVolume = _volumeOscillator.Result[index - 1];
            pre2Volume = _volumeOscillator.Result[index - 2];

            if (currentVolume >= preVolume)
            {
                Plus[index] = currentVolume;
            }
            else
            {
                Minus[index] = currentVolume;
            }

            // Normalization of histogram painting
            if (preVolume >= pre2Volume)
            {
                Plus[index - 1] = preVolume;
            }
            else
            {
                Minus[index - 1] = preVolume;
            }

        }

    }
}





Please Note: Also to overlay on it TSMA - 100 and 200 periods and TMA - 50
The code can be found in the indicator library.


 

 


@hitechee