Category Trend  Published on 06/05/2020

Heiken Ashi Pro

Description

Hi, I'm a full-time IOS developer and a trader as well. I'm a trend trader. I found Heiken Ashi is one of the best trend indicators. then I found people feel difficulty to find the current price action on Heiken Ashi Candle because of the original candle hidden in the back of the Heiken ASHI candle. Heiken Ashi shows only the direction of a trend in the current time period, not the correct current price. that's why I decided to build a new modified version of it.

Modified Version: 

you can use it in two ways 

way 1: 

you can clearly see the blue dots that shows the current price. and Heiken Ashi Candles show the direction of the trend. to get the correct results confirm the upper timeframe trend direction is in the same direction too.

way 2:

you can clearly see that the trend line changes its color that line is of the open price of Heiken Ashi . in this way you can clearly see the original candleStick of the chart and as well as the Heiken Ashi  Trend direction. hope it can help you in your trading.

HAopen = (previous HAopen + previous HAclose)/2    

HAclose = (open+high+low+close)/4

HAhigh =  Max(high,HAopen,HAclose)

HAlow = Min(low,HAopen,HAclose)

 

Note:- 

don't use any indicator if you don't understand its mathematical Calculation.

youtube: 

 

use the modified version of Heiken Ashi (TrendZone price indicator, link given above on the top), with this EA

Feel free to visit my profile:

Fiverr: 

=====================================

Linkedin: https://www.linkedin.com/in/zunisoft/

Whatsapp: +923074194244

call: +923360550104

Facebook: web.facebook.com/uog.nabeel

 

 


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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class HeikenAshiPro : Indicator
    {


        ////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////
        ////////////////  Variables ...........................!
        ////////////////////////////////////////////////////////

        private IndicatorDataSeries _haOpen;
        private IndicatorDataSeries _haClose;
        private IndicatorDataSeries _haHigh;
        private IndicatorDataSeries _haLow;



        [Parameter("Default ChartType", DefaultValue = true)]
        public bool type { get; set; }




        private int previousZoomLevel = 5;







        ////////////////////////////////////////////////////////////////////////
        ////////// initializer ................................................!
        ////////////////////////////////////////////////////////////////////////

        protected override void Initialize()
        {
            previousZoomLevel = Chart.ZoomLevel;
            _haOpen = CreateDataSeries();
            _haClose = CreateDataSeries();
            _haHigh = CreateDataSeries();
            _haLow = CreateDataSeries();

        }


        /////////////////////////////////////////////////////////////////////////
        /////// Calculation ....................................................!
        /////////////////////////////////////////////////////////////////////////

        public override void Calculate(int index)
        {

            var open = Bars.OpenPrices[index];
            var high = Bars.HighPrices[index];
            var low = Bars.LowPrices[index];
            var close = Bars.ClosePrices[index];
            var time = Bars.OpenTimes[index];

            var haClose = (open + high + low + close) / 4;
            var haOpen = (index > 0) ? (_haOpen[index - 1] + _haClose[index - 1]) / 2 : (open + close) / 2;
            var haHigh = Math.Max(Math.Max(high, haOpen), haClose);
            var haLow = Math.Min(Math.Min(low, haOpen), haClose);

            _haOpen[index] = haOpen;
            _haHigh[index] = haHigh;
            _haLow[index] = haLow;
            _haClose[index] = haClose;


            if (type)
            {
                Chart.ChartType = ChartType.Line;
                drawCandle(index, time, haOpen, haHigh, haLow, haClose);
            }
            else
            {
                drawTrendLine(index, Bars.OpenTimes[index - 1], _haOpen[index - 1], time, haOpen, haClose);
            }

        }






        //////////////////////////////////////////////////////////////////////////////////////
        //////////////////   Custion Funcitons ..............................................!
        //////////////////////////////////////////////////////////////////////////////////////

        void drawTrendLine(int id, DateTime time1, double open1, DateTime time2, double open2, double close2)
        {
            var clr = close2 > open2 ? Color.ForestGreen : Color.OrangeRed;
            Chart.DrawTrendLine("trendline" + id, time1, open1, time2, open2, clr, 2);
        }


        void drawCandle(int id, DateTime t, double open, double high, double low, double close)
        {

            var clr = close > open ? Color.ForestGreen : Color.OrangeRed;
            Chart.DrawTrendLine("candlebody" + id, t, open, t, close, clr, candlewidth(Chart.ZoomLevel));
            Chart.DrawTrendLine("candlewick" + id, t, high, t, low, clr, 1);

            Chart.DrawEllipse("price" + id, t, Bars.ClosePrices.LastValue, t, Bars.ClosePrices.LastValue, Color.Blue, 8);
            resetCandlewidth();

        }



        int candlewidth(int zoomlevel)
        {
            return zoomlevel <= 10 ? 1 : (zoomlevel <= 20 ? 2 : (zoomlevel <= 40 ? 5 : (zoomlevel <= 80 ? 10 : (zoomlevel <= 180 ? 20 : (zoomlevel <= 320 ? 40 : (60))))));
        }





        void resetCandlewidth()
        {
            if (previousZoomLevel != Chart.ZoomLevel)
            {
                previousZoomLevel = Chart.ZoomLevel;
                for (int i = 0; i < _haOpen.Count; i++)
                {
                    var time = Bars.OpenTimes[i];
                    var haclr = _haClose[i] > _haOpen[i] ? Color.ForestGreen : Color.OrangeRed;
                    Chart.DrawTrendLine("candlebody" + i, time, _haOpen[i], time, _haClose[i], haclr, candlewidth(Chart.ZoomLevel));

                    var dotwidth = Chart.ZoomLevel <= 80 ? 5 : 8;
                    Chart.DrawEllipse("price" + i, time, Bars.ClosePrices[i], time, Bars.ClosePrices[i], Color.Blue, dotwidth);
                }
            }
        }



    }
}


ZuniSoft's avatar
ZuniSoft

Joined on 11.03.2019

  • Distribution: Paid
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Heiken Ashi Pro.algo
  • Rating: 5
  • Installs: 2057
Comments
Log in to add a comment.
ZuniSoft's avatar
ZuniSoft's avatar
ZuniSoft · 4 years ago

yes, I'm building a trend bot in which Heiken Ashi is only a part of it. 
objectives:

- Multi-timeframe trend direction

- dynamic SL,TP

- SL based upon ATR calculations

- TP based on reversals

 

please wait for it.