Category Trend  Published on 07/10/2020

Heiken Ashi Experto

Description

This is a Heiken Ashi with a much Better Look. This version do not changes the form of the candle but just its colors. 

It comes with the option of having at least four different colors, to distinguish from Bear and Bull candles in a Bull Trend or a Bear Trend.

It will give you a much Cleaner Vision of the candles. Enjoy!!!

 

Grupo CTrader em Portugues -->>  https://t.me/ComunidadeCtrader

Para los que quieran participar de un Grupo CTrader en Español poder compartir estrategias, indicadores e mucho más, aquí abajo les dejo el link.

Grupo CTrader en Español -->> https://t.me/ComunidadCtrader

 


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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class HeikenAshiExperto : Indicator
    {
        [Parameter("Bull Up color", DefaultValue = "RoyalBlue")]
        public string BullUpColor { get; set; }

        [Parameter("Bull Down color", DefaultValue = "Blue")]
        public string BullDownColor { get; set; }

        [Parameter("Bear Down color", DefaultValue = "Coral")]
        public string BearDownColor { get; set; }

        [Parameter("Bear Up color", DefaultValue = "Red")]
        public string BearUpColor { get; set; }

        private Color Bull_upColor;
        private Color Bull_downColor;

        private Color Bear_downColor;
        private Color Bear_upColor;

        private IndicatorDataSeries HeikenOpen;
        private IndicatorDataSeries HeikenClose;
        public Color color;

        public DataSeries Close;
        public DataSeries Open;

        protected override void Initialize()
        {
            Close = Bars.ClosePrices;
            Open = Bars.OpenPrices;

            HeikenOpen = CreateDataSeries();
            HeikenClose = CreateDataSeries();

            Bull_upColor = Color.FromName(BullUpColor);
            Bull_downColor = Color.FromName(BullDownColor);

            Bear_downColor = Color.FromName(BearDownColor);
            Bear_upColor = Color.FromName(BearUpColor);
        }

        public override void Calculate(int index)
        {
            var Heiken_Close = Bars.WeightedPrices[index];

            double Heiken_Open;
            if (index > 0)
                Heiken_Open = (HeikenOpen[index - 1] + HeikenClose[index - 1]) / 2;
            else
                Heiken_Open = (Open[index] + Close[index]) / 2;
            if (Heiken_Open > Heiken_Close)
            {
                if (Bars.ClosePrices[index] >= Bars.OpenPrices[index])
                    Chart.SetBarColor(index, Color.FromName(BearUpColor));
                else if (Bars.ClosePrices[index] < Bars.OpenPrices[index])
                    Chart.SetBarColor(index, Color.FromName(BearDownColor));
            }
            else
            {
                if (Bars.ClosePrices[index] >= Bars.OpenPrices[index])
                    Chart.SetBarColor(index, Color.FromName(BullUpColor));
                else if (Bars.ClosePrices[index] < Bars.OpenPrices[index])
                    Chart.SetBarColor(index, Color.FromName(BullDownColor));
            }
            HeikenOpen[index] = Heiken_Open;
            HeikenClose[index] = Heiken_Close;
        }
    }
}


TraderExperto's avatar
TraderExperto

Joined on 07.06.2019

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Heiken Ashi Experto.algo
  • Rating: 5
  • Installs: 3015
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.