Category Other  Published on 18/08/2023

Bollinger Band V3.0

An update for this algorithm is currently pending moderation. Please revisit this page shortly to access the algorithm's latest version.
Description

This indicator is a new smoothing calculation method for the moving average, and it is adapted to the Bollinger band to achieve this result.

This project consists of 6 entry strategies and you can choose all of them in parametter.

Test it before adopting it!

Have fun, and for any collaboration, contact me !!!

On telegram : https://t.me/nimi012 (direct messaging)

On Discord: https://discord.gg/jNg7BSCh  (I advise you to come and see, Money management strategies and Signals Strategies !)

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
{
    [Cloud("Cloud", "Cloud 6", Opacity = 1)]
    [Cloud("Cloud", "Cloud 5", Opacity = 1)]
    [Cloud("Cloud", "Cloud 4", Opacity = 1)]
    [Cloud("Cloud", "Cloud 3", Opacity = 1)]
    [Cloud("Cloud", "Cloud 2", Opacity = 1)]
    [Cloud("Cloud", "Cloud 1", Opacity = 1)]

    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class BollingerIconHighPerformV30 : Indicator
    {

        [Parameter("Boll Periods", DefaultValue = 8, Group = " RSI Setting")]
        public int PeriodsBoll { get; set; }
        [Parameter("Periods Boll Multi  ", DefaultValue = 1.618, Group = " RSI Setting")]
        public double PeriodsMultiBoll { get; set; }

        [Parameter("Boll Dev", DefaultValue = 0.5, Group = " RSI Setting")]
        public double DevBoll { get; set; }
        [Parameter("Dev Boll Multi  ", DefaultValue = 1.618, Group = " RSI Setting")]
        public double DevMultiBoll { get; set; }

        [Parameter("Boll Ma Type", DefaultValue = MovingAverageType.Exponential, Group = "Periods Settings")]
        public MovingAverageType BollMaType { get; set; }

        [Parameter("Use Color Bars ?", DefaultValue = EnumColorBars.Color_Smooth, Group = "Colors Settings")]
        public EnumColorBars ColorBars { get; set; }

        public enum EnumColorBars
        {
            Color_Sensitive,
            Color_Smooth,
            None
        }
        [Parameter("Boll Ma Type", DefaultValue = EnumIcon.Enter_Sensitive_OverBought, Group = "Periods Settings")]
        public EnumIcon Icon { get; set; }

        public enum EnumIcon
        {
            All_Enter_Sensitive_OverBought,
            All_Enter_Smooth_OverBought,
            Enter_Sensitive_OverBought,
            Enter_Smooth_OverBought,

            ______________________________________,

            All_Enter_Cross,
            All_Enter_Reverse_Cross_OverBought,
            _______________________________________,
            None
        }

        [Output("Cloud", LineColor = "1101FF01")]
        public IndicatorDataSeries Result { get; set; }

        [Output("Cloud 1", LineColor = "13FE0000")]
        public IndicatorDataSeries ResultBollCloudMiddle { get; set; }
        [Output("Cloud 2", LineColor = "13FE0000")]
        public IndicatorDataSeries ResultBollCloudMiddle2 { get; set; }
        [Output("Cloud 3", LineColor = "13FE0000")]
        public IndicatorDataSeries ResultBollCloudMiddle3 { get; set; }
        [Output("Cloud 4", LineColor = "13FE0000")]
        public IndicatorDataSeries ResultBollCloudMiddle4 { get; set; }
        [Output("Cloud 5", LineColor = "13FE0000")]
        public IndicatorDataSeries ResultBollCloudMiddle5 { get; set; }
        [Output("Cloud 6", LineColor = "13FE0000")]
        public IndicatorDataSeries ResultBollCloudMiddle6 { get; set; }

        [Output("Boll  Middle ", LineColor = "Yellow", LineStyle = LineStyle.Solid, PlotType = PlotType.Line)]
        public IndicatorDataSeries ResultBollMiddle { get; set; }

        [Output("Boll Top ", LineColor = "3C00FF00")]
        public IndicatorDataSeries ResultBollTop { get; set; }
        [Output("Boll Bottom ", LineColor = "42FF0000")]
        public IndicatorDataSeries ResultBollBottom { get; set; }

        [Output("Boll 2 Top ", LineColor = "3C00FF00")]
        public IndicatorDataSeries ResultBoll2Top { get; set; }
        [Output("Boll 2 Bottom ", LineColor = "42FF0000")]
        public IndicatorDataSeries ResultBoll2Bottom { get; set; }

        [Output("Boll 3 Top ", LineColor = "3C00FF00")]
        public IndicatorDataSeries ResultBoll3Top { get; set; }
        [Output("Boll 3 Bottom ", LineColor = "42FF0000")]
        public IndicatorDataSeries ResultBoll3Bottom { get; set; }

        [Output("Boll 4 Top ", LineColor = "3C00FF00")]
        public IndicatorDataSeries ResultBoll4Top { get; set; }
        [Output("Boll4 Bottom ", LineColor = "42FF0000")]
        public IndicatorDataSeries ResultBoll4Bottom { get; set; }

        private BollingerBands[,] boll;
        private int[] periodsBoll;
        private double[] devBoll;
        private int direction;
        private MovingAverage ma;
        private AverageTrueRange atr;
        private IndicatorDataSeries[] resTop, resMiddle, resBottom;
        private IndicatorDataSeries countData, countUp, countDown;

        private Color a, b, c, d, e, f, g, h, i, j, k, l;

        protected override void Initialize()
        {
            atr = Indicators.AverageTrueRange(50, MovingAverageType.Simple);
            countData = CreateDataSeries();
            countUp = CreateDataSeries();
            countDown = CreateDataSeries();
            ma = Indicators.MovingAverage(Bars.MedianPrices, 1, MovingAverageType.Exponential);
            periodsBoll = new int[6];
            devBoll = new double[6];
            resTop = new IndicatorDataSeries[6];
            resMiddle = new IndicatorDataSeries[6];
            resBottom = new IndicatorDataSeries[6];

            boll = new BollingerBands[6, 6];
            for (int i = 0; i < 6; i++)
            {
                periodsBoll[i] = (int)(Math.Round(Math.Pow(PeriodsMultiBoll, i) * PeriodsBoll));
                resTop[i] = CreateDataSeries();
                resMiddle[i] = CreateDataSeries();
                resBottom[i] = CreateDataSeries();

                for (int j = 0; j < resTop.Length; j++)
                {
                    devBoll[j] = (Math.Pow(DevMultiBoll, j) * DevBoll);

                    boll[i, j] = Indicators.BollingerBands(Bars.MedianPrices, periodsBoll[i], devBoll[j], BollMaType);

                    //Print(devBoll[j]);
                }
            }
        }

        public override void Calculate(int index)
        {
            if (index < periodsBoll[5])
                return;
            Result[index] = ma.Result.Last(0);

            for (int i = 0; i < 6; i++)
            {
                var top = double.MinValue;
                var bottom = double.MaxValue;

                for (int j = 0; j < 6; j++)
                {
                    var top2 = boll[j, i].Top.Last(0);
                    resTop[i][index] = top2 > top ? top2 : top;

                    var bottom2 = boll[j, i].Bottom.Last(0);
                    resBottom[i][index] = bottom2 < bottom ? bottom2 : bottom;

                    resMiddle[i][index] = (resTop[i][index] - resBottom[i][index]) / 2 + resBottom[i][index];
                }
            }

            ResultBollTop[index] = resTop[0][index] == double.MinValue ? double.NaN : resTop[0][index];
            ResultBollBottom[index] = resBottom[0][index] == double.MaxValue ? double.NaN : resBottom[0][index];
            ResultBollMiddle[index] = resMiddle[0][index] == double.MaxValue ? double.NaN : resMiddle[0][index] == double.MinValue ? double.NaN : resMiddle[0][index];
            ResultBoll2Top[index] = resTop[1][index] == double.MinValue ? double.NaN : resTop[1][index];
            ResultBoll2Bottom[index] = resBottom[1][index] == double.MaxValue ? double.NaN : resBottom[1][index];
            ResultBoll3Top[index] = resTop[2][index] == double.MinValue ? double.NaN : resTop[2][index];
            ResultBoll3Bottom[index] = resBottom[2][index] == double.MaxValue ? double.NaN : resBottom[2][index];
            ResultBoll3Top[index] = resTop[3][index] == double.MinValue ? double.NaN : resTop[3][index];
            ResultBoll3Bottom[index] = resBottom[3][index] == double.MaxValue ? double.NaN : resBottom[3][index];
            ResultBoll4Top[index] = resTop[4][index] == double.MinValue ? double.NaN : resTop[4][index];
            ResultBoll4Bottom[index] = resBottom[4][index] == double.MaxValue ? double.NaN : resBottom[4][index];

            if (ColorBars != EnumColorBars.None)
            {
                ResultBollCloudMiddle[index] = boll[0, 0].Main.Last(0);
                ResultBollCloudMiddle2[index] = boll[1, 0].Main.Last(0);
                ResultBollCloudMiddle3[index] = boll[2, 0].Main.Last(0);
                ResultBollCloudMiddle4[index] = boll[3, 0].Main.Last(0);
                ResultBollCloudMiddle5[index] = boll[4, 0].Main.Last(0);
                ResultBollCloudMiddle6[index] = boll[5, 0].Main.Last(0);
                countUp[index] = 0;
                countDown[index] = 0;

                for (int i = 0; i < 6; i++)
                {
                    if (Bars.ClosePrices.Last(0) > boll[i, 0].Main.Last(0))
                    {
                        countUp[index]++;
                    }

                    if (Bars.ClosePrices.Last(0) < boll[i, 0].Main.Last(0))
                    {
                        countDown[index]++;
                    }

                }

                countData[index] = countUp[index] > countDown[index] ? 1 : countUp[index] < countDown[index] ? -1 : 0;

                if (Icon != EnumIcon.None)
                {

                    var espaceIcon = atr.Result.Last(0);
                    if (Icon == EnumIcon.All_Enter_Reverse_Cross_OverBought || Icon == EnumIcon.Enter_Smooth_OverBought || Icon == EnumIcon.All_Enter_Smooth_OverBought || Icon == EnumIcon.Enter_Sensitive_OverBought || (Icon == EnumIcon.All_Enter_Sensitive_OverBought))

                    {
                        if (Bars.LowPrices.Last(0) < ResultBoll4Bottom[index])
                        {
                            direction = -1;
                        }

                        if (Bars.HighPrices.Last(0) > ResultBoll4Top[index])
                        {
                            direction = 1;
                        }
                    }

                    if (Icon == EnumIcon.Enter_Smooth_OverBought || Icon == EnumIcon.All_Enter_Smooth_OverBought)
                    {
                        if (Bars.TypicalPrices.Last(0) < ResultBollMiddle[index] && Bars.TypicalPrices.Last(1) > ResultBollMiddle[index - 1] && direction == 1)
                        {
                            Chart.DrawIcon("OverSell" + index, ChartIconType.DownArrow, index, Bars.HighPrices.Last(0) + espaceIcon, Color.Red);

                            if (Icon != EnumIcon.All_Enter_Smooth_OverBought)
                                direction = 0;
                        }

                        if (Bars.TypicalPrices.Last(0) > ResultBollMiddle[index] && Bars.TypicalPrices.Last(1) < ResultBollMiddle[index - 1] && direction == -1)
                        {
                            Chart.DrawIcon("OverBuy" + index, ChartIconType.UpArrow, index, Bars.LowPrices.Last(0) - espaceIcon, Color.Lime);

                            if (Icon != EnumIcon.All_Enter_Smooth_OverBought)
                                direction = 0;
                        }
                    }
                    if (Icon == EnumIcon.Enter_Sensitive_OverBought || (Icon == EnumIcon.All_Enter_Sensitive_OverBought))
                    {
                        if (countData[index] < countData[index - 1] && countData[index] != 0 && direction == 1)
                        {
                            Chart.DrawIcon("OverSell" + index, ChartIconType.DownArrow, index, Bars.HighPrices.Last(0) + espaceIcon, Color.Red);
                            if (Icon != EnumIcon.All_Enter_Sensitive_OverBought)
                                direction = 0;
                        }

                        if (countData[index] > countData[index - 1] && countData[index] != 0 && direction == -1)
                        {
                            Chart.DrawIcon("OverBuy" + index, ChartIconType.UpArrow, index, Bars.LowPrices.Last(0) - espaceIcon, Color.Lime);
                            if (Icon != EnumIcon.All_Enter_Sensitive_OverBought)
                                direction = 0;
                        }
                    }

                    if (Icon == EnumIcon.Enter_Sensitive_OverBought || (Icon == EnumIcon.All_Enter_Sensitive_OverBought))
                    {
                        if (countData[index] < countData[index - 1] && countData[index] != 0 && direction == 1)
                        {
                            Chart.DrawIcon("OverSell" + index, ChartIconType.DownArrow, index, Bars.HighPrices.Last(0) + espaceIcon, Color.Red);
                            if (Icon != EnumIcon.All_Enter_Sensitive_OverBought)
                                direction = 0;
                        }

                        if (countData[index] > countData[index - 1] && countData[index] != 0 && direction == -1)
                        {
                            Chart.DrawIcon("OverBuy" + index, ChartIconType.UpArrow, index, Bars.LowPrices.Last(0) - espaceIcon, Color.Lime);
                            if (Icon != EnumIcon.All_Enter_Sensitive_OverBought)
                                direction = 0;
                        }
                    }
                    if (Icon == EnumIcon.All_Enter_Reverse_Cross_OverBought)
                    {
                        if (Bars.TypicalPrices.Last(0) > ResultBollMiddle[index] && countData[index] <= 0 && direction == 1
                        && (Bars.TypicalPrices.HasCrossedBelow(ResultBollTop[index], 1)
                         || Bars.TypicalPrices.HasCrossedBelow(ResultBoll2Top[index], 1)
                         || Bars.TypicalPrices.HasCrossedBelow(ResultBoll3Top[index], 1)
                         || Bars.TypicalPrices.HasCrossedBelow(ResultBoll4Top[index], 1)))

                        {
                            Chart.DrawIcon("OverSell" + index, ChartIconType.DownArrow, index, Bars.HighPrices.Last(0) + espaceIcon, Color.Red);
                            //direction = 0;
                        }

                        if (Bars.TypicalPrices.Last(0) < ResultBollMiddle[index] && countData[index] >= 0 && direction == -1
                        && (Bars.TypicalPrices.HasCrossedAbove(ResultBollBottom[index], 1)
                         || Bars.TypicalPrices.HasCrossedAbove(ResultBoll2Bottom[index], 1)
                         || Bars.TypicalPrices.HasCrossedAbove(ResultBoll3Bottom[index], 1)
                         || Bars.TypicalPrices.HasCrossedAbove(ResultBoll4Bottom[index], 1)))
                        {
                            Chart.DrawIcon("OverBuy" + index, ChartIconType.UpArrow, index, Bars.LowPrices.Last(0) - espaceIcon, Color.Lime);
                            //direction = 0;
                        }
                    }

                    if (Icon == EnumIcon.All_Enter_Cross)
                    {
                        if (Bars.TypicalPrices.Last(0) < ResultBollMiddle[index] && countData[index] < 0
                        && (Bars.TypicalPrices.HasCrossedBelow(ResultBollBottom[index], 2)
                         || Bars.TypicalPrices.HasCrossedBelow(ResultBoll2Bottom[index], 2)
                         || Bars.TypicalPrices.HasCrossedBelow(ResultBoll3Bottom[index], 2)
                         || Bars.TypicalPrices.HasCrossedBelow(ResultBoll4Bottom[index], 2)))


                        {
                            Chart.DrawIcon("OverSell" + index, ChartIconType.DownArrow, index, Bars.HighPrices.Last(0) + espaceIcon, Color.Red);

                        }

                        if (Bars.TypicalPrices.Last(0) > ResultBollMiddle[index] && countData[index] > 0
                        && (Bars.TypicalPrices.HasCrossedAbove(ResultBollTop[index], 2)
                         || Bars.TypicalPrices.HasCrossedAbove(ResultBoll2Top[index], 2)
                         || Bars.TypicalPrices.HasCrossedAbove(ResultBoll3Top[index], 2)
                         || Bars.TypicalPrices.HasCrossedAbove(ResultBoll4Top[index], 2)))
                        {
                            Chart.DrawIcon("OverBuy" + index, ChartIconType.UpArrow, index, Bars.LowPrices.Last(0) - espaceIcon, Color.Lime);


                        }
                    }
                }
                if (ColorBars == EnumColorBars.Color_Sensitive)
                {

                    int opacity = (int)(countUp[index] > countDown[index] ? countUp[index] * 255 / 6 : countUp[index] < countDown[index] ? countDown[index] * 255 / 6 : 50);
                    var color = countUp[index] > countDown[index] ? Color.Lime : countUp[index] < countDown[index] ? Color.Red : Color.DarkGray;

                    a = Color.FromArgb(opacity, color);

                    Chart.SetBarColor(index, a);
                }
                if (ColorBars == EnumColorBars.Color_Smooth)
                {
                    var opacity = (int)(countUp[index] > countDown[index] ? countUp[index] * 255 / 6 : countUp[index] < countDown[index] ? countDown[index] * 255 / 6 : 50);

                    a = Color.FromArgb(opacity, Color.Lime);
                    b = Color.FromArgb(opacity, Color.Lime);
                    c = Color.FromArgb(opacity, Color.Lime);
                    d = Color.FromArgb(opacity, Color.Lime);
                    e = Color.FromArgb(opacity, Color.Lime);
                    f = Color.FromArgb(opacity, Color.Lime);


                    g = Color.FromArgb(opacity, Color.Red);
                    h = Color.FromArgb(opacity, Color.Red);
                    i = Color.FromArgb(opacity, Color.Red);
                    j = Color.FromArgb(opacity, Color.Red);
                    k = Color.FromArgb(opacity, Color.Red);
                    l = Color.FromArgb(opacity, Color.Red);

                    if (ResultBollMiddle[index] > ResultBollMiddle[index - 1])
                    {
                        if (Bars.TypicalPrices.Last(0) > ResultBollMiddle[index])
                        {
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, a);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle2[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, b);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle3[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle2[index])
                                Chart.SetBarColor(index, c);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle4[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle3[index])
                                Chart.SetBarColor(index, d);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle5[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle4[index])
                                Chart.SetBarColor(index, e);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle6[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle5[index])
                                Chart.SetBarColor(index, f);

                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, g);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle2[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, h);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle3[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle2[index])
                                Chart.SetBarColor(index, i);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle4[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle3[index])
                                Chart.SetBarColor(index, j);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle5[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle4[index])
                                Chart.SetBarColor(index, k);
                            if (((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle6[index] && ((Bars.HighPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle5[index])
                                Chart.SetBarColor(index, l);
                        }
                        if (Bars.TypicalPrices.Last(0) < ResultBollMiddle[index])
                        {
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, l);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle2[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, k);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle3[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle2[index])
                                Chart.SetBarColor(index, j);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle4[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle3[index])
                                Chart.SetBarColor(index, i);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle5[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle4[index])
                                Chart.SetBarColor(index, h);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle6[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle5[index])
                                Chart.SetBarColor(index, g);

                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, f);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle2[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, d);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle3[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle2[index])
                                Chart.SetBarColor(index, d);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle4[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle3[index])
                                Chart.SetBarColor(index, c);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle5[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle4[index])
                                Chart.SetBarColor(index, b);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle6[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle5[index])
                                Chart.SetBarColor(index, a);

                        }
                    }
                    if (ResultBollMiddle[index] < ResultBollMiddle[index - 1])
                    {
                        if (Bars.TypicalPrices.Last(0) < ResultBollMiddle[index])
                        {
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, a);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle2[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, b);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle3[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle2[index])
                                Chart.SetBarColor(index, c);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle4[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle3[index])
                                Chart.SetBarColor(index, d);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle5[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle4[index])
                                Chart.SetBarColor(index, e);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle6[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle5[index])
                                Chart.SetBarColor(index, f);

                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, g);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle2[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, h);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle3[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle2[index])
                                Chart.SetBarColor(index, i);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle4[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle3[index])
                                Chart.SetBarColor(index, j);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle5[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle4[index])
                                Chart.SetBarColor(index, k);
                            if (((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle6[index] && ((Bars.LowPrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle5[index])
                                Chart.SetBarColor(index, l);
                        }
                        if (Bars.TypicalPrices.Last(0) > ResultBollMiddle[index])
                        {
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, l);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle2[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, k);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle3[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle2[index])
                                Chart.SetBarColor(index, j);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle4[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle3[index])
                                Chart.SetBarColor(index, i);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle5[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle4[index])
                                Chart.SetBarColor(index, h);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle6[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle5[index])
                                Chart.SetBarColor(index, g);

                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, f);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle2[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle[index])
                                Chart.SetBarColor(index, e);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle3[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle2[index])
                                Chart.SetBarColor(index, d);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle4[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle3[index])
                                Chart.SetBarColor(index, c);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle5[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle4[index])
                                Chart.SetBarColor(index, b);
                            if (((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollMiddle[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) < ResultBollCloudMiddle6[index] && ((Bars.ClosePrices.Last(0) + Bars.MedianPrices.Last(0)) / 2) > ResultBollCloudMiddle5[index])
                                Chart.SetBarColor(index, a);

                        }
                    }
                }
            }

        }
    }
}



YE
YesOrNot

Joined on 10.10.2022 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Bollinger Icon High Perform V 3.0.algo
  • Rating: 5
  • Installs: 677
  • Modified: 18/08/2023 22:40
Comments
Log in to add a comment.
VE
VEI5S6C4OUNT0 · 1 year ago

I was totaly missing an argument for the clouds

print (FACEPALM)

 I fixed it and added option for cloud …(EnumCloud) 

Thank you for responding.

YE
YesOrNot · 1 year ago

Hi Splash the, 

Can you explain me exactly what you wanna make ? 

For collaboration my telegram here : https://t.me/nimi012

 

VE
VEI5S6C4OUNT0 · 1 year ago

I learned a lot of how you coded this and I like it so I made something like it with Expernatial MA and or other MA's as source for ATR however I am having trouble with the cloud part…

 

 

using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo
{

   //[Cloud("Up1", "Dn5", Opacity = 1)]
   //[Cloud("Up1", "Dn4", Opacity = 1)]
   //[Cloud("Up1", "Dn3", Opacity = 1)]
   //[Cloud("Up1", "Dn2", Opacity = 1)]
   [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class MAL3 : Indicator
     { 
       public DataSeries Source { get; set; }
       
       [Parameter("P 1", DefaultValue = 8)]
       public int P1 { get; set; }
       [Parameter("P 2", DefaultValue = 34)]
       public int P2 { get; set; }
       [Parameter("P 3", DefaultValue = 96)]
       public int P3 { get; set; }
       [Parameter("P 4", DefaultValue = 408)]
       public int P4 { get; set; }
       [Parameter("P 5", DefaultValue = 816)]
       public int P5 { get; set; }
       [Parameter("M A", DefaultValue = MovingAverageType.Exponential )]
       public MovingAverageType MAType { get; set; }
       
       [Output("Up1", LineColor = "AA00FF00", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Up1 { get; set; }
       
       [Output("Dn1", LineColor = "AAFF0000", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Dn1 { get; set; }
       
       [Output("Up2", LineColor = "AA00FF00", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Up2 { get; set; }
       
       [Output("Dn2", LineColor = "AAFF0000", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Dn2 { get; set; }
       
       [Output("Up3", LineColor = "AA00FF00", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Up3 { get; set; }
       
       [Output("Dn3", LineColor = "AAFF0000", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Dn3 { get; set; }
       
       [Output("Up4", LineColor = "AA00FF00", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Up4 { get; set; }
       
       [Output("Dn4", LineColor = "AAFF0000", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Dn4 { get; set; }
       
       [Output("Up5", LineColor = "AA00FF00", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Up5 { get; set; }
       
       [Output("Dn5", LineColor = "AAFF0000", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries Dn5 { get; set; }
       
       
       MovingAverage M1;
       MovingAverage M2;
       MovingAverage M3;
       MovingAverage M4;
       MovingAverage M5;
       
       MovingAverage MATR;
       AverageTrueRange ATR;
       AverageTrueRange ATRA;
       
       [Parameter("E Cross Arrows ?", DefaultValue = EnumColorArrows.Yes)]
       public EnumColorArrows ColorArrowsE { get; set; }
       
       [Parameter("A2 Cross Arrows ?", DefaultValue = EnumColorArrows.Yes)]
       public EnumColorArrows ColorArrowsA { get; set; }
       
       [Parameter("Use Color Bars ?", DefaultValue = EnumColorBars.M3)]
       public EnumColorBars ColorBars { get; set; }
       
       [Parameter("Use Color EX Bars ?", DefaultValue = EnumColorXBars.Yes)]
       public EnumColorXBars ColorBarsX { get; set; }
       
       [Parameter("Up Bars",DefaultValue = "8800FF00")]
       public Color UpB { get; set; }
       
       [Parameter("Dn Bars",DefaultValue = "88FF0000")]
       public Color DnB { get; set; }
       
       [Parameter("Up Bars X",DefaultValue = "FF00FF00")]
       public Color UpBX { get; set; }
       
       [Parameter("Dn Bars X",DefaultValue = "FFFF0000")]
       public Color DnBX { get; set; }
       
       [Parameter("Up Bars 2",DefaultValue = "CCFFFF00")]
       public Color UpB2 { get; set; }
       
       [Parameter("Dn Bars 2",DefaultValue = "CCAA00FF")]
       public Color DnB2 { get; set; }
       
       [Parameter("Up Arrows",DefaultValue = "FF00FF00")]
       public Color UpA { get; set; }
       
       [Parameter("Dn Arrows",DefaultValue = "FFFF0000")]
       public Color DnA { get; set; }
       
       [Parameter("ATR Period",DefaultValue = 14)]
       public int ATRP { get; set; }
       
       [Parameter("ATR Type", DefaultValue = MovingAverageType.Simple )]
       public MovingAverageType ATRType { get; set; }
       
       [Output("Up ATR 1", LineColor = "88AA00FF", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries UpATR1 { get; set; }
       
       [Output("Dn ATR 1", LineColor = "88AA00FF", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries DnATR1 { get; set; }
       
       [Output("Up ATR 2", LineColor = "44FFFF00", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries UpATR2 { get; set; }
       
       [Output("Dn ATR 2", LineColor = "44FFFF00", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries DnATR2 { get; set; }
       
       [Output("UpA1", LineColor = "CCFFFF00", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries UpA1 { get; set; }
       
       [Output("DnA1", LineColor = "CCAA00FF", PlotType = PlotType.DiscontinuousLine, Thickness = 1)]
       public IndicatorDataSeries DnA1 { get; set; }
       
       public enum EnumColorArrows
       {
           Yes,No
       }
       public enum EnumColorBars
       {
           M1,M2,M3,M4,M5,ATR,OFF
       }
       public enum EnumColorXBars
       {
           Yes,No
       }
       
       protected override void Initialize()
       {
       M1 = Indicators.MovingAverage(Source,P1,MAType);
       M2 = Indicators.MovingAverage(Source,P2,MAType);
       M3 = Indicators.MovingAverage(Source,P3,MAType);
       M4 = Indicators.MovingAverage(Source,P4,MAType);
       M5 = Indicators.MovingAverage(Source,P5,MAType);
       
       MATR = Indicators.MovingAverage (Source , ATRP , ATRType );
       ATR = Indicators.AverageTrueRange(ATRP, ATRType);
       
       ATRA = Indicators.AverageTrueRange(100, MovingAverageType.Exponential);
       }
       public override void Calculate(int index)
       {
        var espace = ATRA.Result.Last(0);
        var Aspace = ATR.Result.Last(0);

           UpATR1[index] = MATR.Result[index] - (Aspace*2);
           DnATR1[index] = MATR.Result[index] + (Aspace*2);
           UpATR2[index] = MATR.Result[index] - (Aspace*5);
           DnATR2[index] = MATR.Result[index] + (Aspace*5);
     
           if (MATR.Result.Last(0) >= MATR.Result.Last(1))
           {
               UpA1[index] = MATR.Result[index];
           }
           if (MATR.Result.Last(0) <= MATR.Result.Last(1))
           {
               DnA1[index] = MATR.Result[index];
           }
           
           if (M1.Result.Last(0) >= M1.Result.Last(1))
           {
               Up1[index] = M1.Result[index];
           }
           if (M1.Result.Last(0) <= M1.Result.Last(1))
           {
               Dn1[index] = M1.Result[index];
           }
           
           if (M2.Result.Last(0) >= M2.Result.Last(1))
           {
               Up2[index] = M2.Result[index];
           }
           if (M2.Result.Last(0) <= M2.Result.Last(1))
           {
               Dn2[index] = M2.Result[index];
           }
           
           if (M3.Result.Last(0) >= M3.Result.Last(1))
           {
               Up3[index] = M3.Result[index];
           }
           if (M3.Result.Last(0) <= M3.Result.Last(1))
           {
               Dn3[index] = M3.Result[index];
           }
           
           if (M4.Result.Last(0) >= M4.Result.Last(1))
           {
               Up4[index] = M4.Result[index];
           }
           if (M4.Result.Last(0) <= M4.Result.Last(1))
           {
               Dn4[index] = M4.Result[index];
           }
           if (M5.Result.Last(0) >= M5.Result.Last(1))
           {
               Up5[index] = M5.Result[index];
           }
           if (M5.Result.Last(0) <= M5.Result.Last(1))
           {
               Dn5[index] = M5.Result[index];
           }
           if (ColorBars == EnumColorBars.M1)
           {
              if (Bars.ClosePrices.Last(0) > M1.Result.Last(0))
                 Chart.SetBarColor(index, UpB);
              
              if (Bars.ClosePrices.Last(0) < M1.Result.Last(0))
                 Chart.SetBarColor(index, DnB);
           }
           if (ColorBars == EnumColorBars.M2)
           {
              if (Bars.ClosePrices.Last(0) > M2.Result.Last(0))
                 Chart.SetBarColor(index, UpB);
              
              if (Bars.ClosePrices.Last(0) < M2.Result.Last(0))
                 Chart.SetBarColor(index, DnB);
           }
           if (ColorBars == EnumColorBars.M3)
           {
              if (Bars.ClosePrices.Last(0) > M3.Result.Last(0))
                 Chart.SetBarColor(index, UpB);
              
              if (Bars.ClosePrices.Last(0) < M3.Result.Last(0))
                 Chart.SetBarColor(index, DnB);
           }
           if (ColorBars == EnumColorBars.M4)
           {
              if (Bars.ClosePrices.Last(0) > M4.Result.Last(0))
                 Chart.SetBarColor(index, UpB);
              
              if (Bars.ClosePrices.Last(0) < M4.Result.Last(0))
                 Chart.SetBarColor(index, DnB);
           }
           if (ColorBars == EnumColorBars.M5)
           {
              if (Bars.ClosePrices.Last(0) > M5.Result.Last(0))
                 Chart.SetBarColor(index, UpB);
              
              if (Bars.ClosePrices.Last(0) < M5.Result.Last(0))
                 Chart.SetBarColor(index, DnB);
           }
           
           if (ColorBars == EnumColorBars.ATR)
           {
              if (Bars.ClosePrices.Last(0) > MATR.Result.Last(0))
                 Chart.SetBarColor(index, UpB2);
              
              if (Bars.ClosePrices.Last(0) < MATR.Result.Last(0))
                 Chart.SetBarColor(index, DnB2);
           }
           if (ColorBarsX == EnumColorXBars.Yes)
           {
              if (Bars.HighPrices.Last(0) > (MATR.Result.Last(0)+Aspace*2))
                 Chart.SetBarColor(index, UpBX);
              
              if (Bars.LowPrices.Last(0) < (MATR.Result.Last(0)-Aspace*2))
                 Chart.SetBarColor(index, DnBX);
           }
           if (ColorArrowsE == EnumColorArrows.Yes)
            {
             if (M1.Result.Last(0) > M2.Result.Last(0) && M1.Result.Last(1) < M2.Result.Last(1) && M1.Result.Last(1) < M3.Result.Last(1))
             {
                Chart.DrawIcon("UP" + index, ChartIconType.UpArrow, index, Bars.LowPrices.Last(0) - espace , UpA);
             }
             if (M1.Result.Last(0) < M2.Result.Last(0) && M1.Result.Last(1) > M2.Result.Last(1) && M1.Result.Last(1) > M3.Result.Last(1))
             {
                Chart.DrawIcon("DN" + index, ChartIconType.DownArrow, index, Bars.HighPrices.Last(0) + espace , DnA);
             }
             }
           if (ColorArrowsA == EnumColorArrows.Yes)
            {
             if (Bars.LowPrices.Last(0) < (MATR.Result.Last(0)-Aspace*2))
              {
                Chart.DrawIcon("UP" + index, ChartIconType.UpArrow, index, Bars.LowPrices.Last(0) - espace , UpA);
              }            
             if (Bars.HighPrices.Last(0) > (MATR.Result.Last(0)+Aspace*2))
              {
                Chart.DrawIcon("DN" + index, ChartIconType.DownArrow, index, Bars.HighPrices.Last(0) + espace , DnA);
              }
           }
           
        }
     }
  }