Category Trend  Published on 06/05/2020

MultiTimeframe Trend EA - Premium

Description

InComplete yet, use in combination with my other indicator. for day trader use M15 time frame with " M15, H1, H4 (bot parameters)". right now bot will not make any trade. will provide you the interface perfectly.

Download from the given link below: TrendZone Price indicator

 

MultiTimeframe Trend EA

Youtube: 

 

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

Please feel free to visit my profile.

Fiverr: 

Email: tb135qet13@gmail.com
LinkedIn: linkedin.com/in/zunisoft/

Whatsapp: +923074197244 

Call: +923360550104 

  


using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.Collections;
using System.Collections.Generic;



namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MultiTimeframeTrendEA : Robot
    {

        [Parameter("M1 Trend", DefaultValue = false)]
        public bool M1Trend { get; set; }

        [Parameter("M5 Trend", DefaultValue = false)]
        public bool M5Trend { get; set; }

        [Parameter("M15 Trend", DefaultValue = false)]
        public bool M15Trend { get; set; }

        [Parameter("M30 Trend", DefaultValue = false)]
        public bool M30Trend { get; set; }

        [Parameter("H1 Trend", DefaultValue = false)]
        public bool H1Trend { get; set; }

        [Parameter("H4 Trend", DefaultValue = false)]
        public bool H4Trend { get; set; }

        [Parameter("Day Trend", DefaultValue = false)]
        public bool D1Trend { get; set; }





        heikenAshi daily = new heikenAshi();
        heikenAshi hour4 = new heikenAshi();
        heikenAshi hour = new heikenAshi();
        heikenAshi min30 = new heikenAshi();
        heikenAshi min15 = new heikenAshi();
        heikenAshi min5 = new heikenAshi();
        heikenAshi min = new heikenAshi();

        protected override void OnStart()
        {
            // Put your initialization logic here

            if (D1Trend)
            {
                daily.bar = MarketData.GetBars(TimeFrame.Daily);
                if (daily.bar.TimeFrame > TimeFrame)
                {
                    daily.createList();
                }
            }
            if (H4Trend)
            {
                hour4.bar = MarketData.GetBars(TimeFrame.Hour4);
                if (hour4.bar.TimeFrame > TimeFrame)
                {
                    hour4.createList();
                }
            }
            if (H1Trend)
            {
                hour.bar = MarketData.GetBars(TimeFrame.Hour);
                if (hour.bar.TimeFrame > TimeFrame)
                {
                    hour.createList();
                }
            }
            if (M30Trend)
            {
                min30.bar = MarketData.GetBars(TimeFrame.Minute30);
                if (min30.bar.TimeFrame > TimeFrame)
                {
                    min30.createList();
                }
            }
            if (M15Trend)
            {
                min15.bar = MarketData.GetBars(TimeFrame.Minute15);
                if (min15.bar.TimeFrame > TimeFrame)
                {
                    min15.createList();
                }
            }
            if (M5Trend)
            {
                min5.bar = MarketData.GetBars(TimeFrame.Minute5);
                if (min5.bar.TimeFrame > TimeFrame)
                {
                    min5.createList();
                }
            }
            if (M1Trend)
            {
                min.bar = MarketData.GetBars(TimeFrame.Minute);
                min.createList();
            }
        }

        protected override void OnTick()
        {
            // Put your core logic here
            if (M1Trend && min.bar.TimeFrame > TimeFrame)
            {
                HATrend(min, 2);
            }
            if (M5Trend && min5.bar.TimeFrame > TimeFrame)
            {
                HATrend(min5, 2);
            }
            if (M15Trend && min15.bar.TimeFrame > TimeFrame)
            {
                HATrend(min15, 2);
            }
            if (M30Trend && min30.bar.TimeFrame > TimeFrame)
            {
                HATrend(min30, 2);
            }
            if (H1Trend && hour.bar.TimeFrame > TimeFrame)
            {
                HATrend(hour, 2);
            }
            if (H4Trend && hour4.bar.TimeFrame > TimeFrame)
            {
                HATrend(hour4, 2);
            }
            if (D1Trend && daily.bar.TimeFrame > TimeFrame)
            {
                HATrend(daily, 2);
            }
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }









        //////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////
        //////  Custom --------------------------------------------------!
        //////////////////////////////////////////////////////////////////
        void HATrend(heikenAshi obj, int thickness)
        {
            obj.updating();

            var timeframe = obj.bar.TimeFrame.ToString();

            var clr = obj.close[obj.index] > obj.open[obj.index] ? Color.ForestGreen : Color.OrangeRed;
            drawTrendLine(timeframe + obj.index, obj.bar, obj.index, obj.bar.OpenTimes[obj.index - 1], obj.open[obj.index - 1], obj.bar.OpenTimes[obj.index], obj.open[obj.index], clr, false, thickness);
            drawTrendLine(timeframe + "helper", obj.bar, obj.index, obj.bar.OpenTimes[obj.index], obj.open[obj.index], Bars.OpenTimes.LastValue, obj.open[obj.index], clr, false, thickness);
            Chart.DrawText(timeframe + "text", timeframe, Bars.OpenTimes.LastValue, obj.open[obj.index], clr);
            Chart.DrawEllipse(timeframe + obj.index, obj.bar.OpenTimes.LastValue, obj.open[obj.index], obj.bar.OpenTimes.LastValue, obj.open[obj.index], Color.White, 3);
        }

        public class heikenAshi
        {
            public List<double> open;
            public List<double> close;
            public List<double> high;
            public List<double> low;
            public List<bool> trend;

            public Bars bar;
            public int index;

            /*    bar = MarketData.GetBars(TimeFrame.Daily)    */

            public void createList()
            {
                open = new List<double>(bar.OpenPrices);
                close = new List<double>(bar.ClosePrices);
                high = new List<double>(bar.HighPrices);
                low = new List<double>(bar.LowPrices);

                bool[] helper = new bool[bar.OpenTimes.Count];
                trend = new List<bool>(helper);

                for (int i = bar.OpenPrices.Count - 5; i < bar.OpenPrices.Count; i++)
                {
                    var o = bar.OpenPrices[i];
                    var h = bar.HighPrices[i];
                    var l = bar.LowPrices[i];
                    var c = bar.ClosePrices[i];

                    var haClose = (o + h + l + c) / 4;
                    var haOpen = (open[i - 1] + close[i - 1]) / 2;
                    var haHigh = Math.Max(Math.Max(h, haOpen), haClose);
                    var haLow = Math.Min(Math.Min(l, haOpen), haClose);

                    open[i] = haOpen;
                    close[i] = haClose;
                    high[i] = haHigh;
                    low[i] = haLow;
                    trend[i] = (haClose > haOpen) ? true : false;
                }


            }


            public void updating()
            {
                index = bar.OpenPrices.Count - 1;
                var o = bar.OpenPrices.LastValue;
                var h = bar.HighPrices.LastValue;
                var l = bar.LowPrices.LastValue;
                var c = bar.ClosePrices.LastValue;

                var haClose = (o + h + l + c) / 4;
                var haOpen = (open[open.Count - 2] + close[close.Count - 2]) / 2;
                var haHigh = Math.Max(Math.Max(h, haOpen), haClose);
                var haLow = Math.Min(Math.Min(l, haOpen), haClose);

                if (bar.OpenPrices.Count > open.Count)
                {
                    open.Add(haOpen);
                    close.Add(haClose);
                    high.Add(haHigh);
                    low.Add(haLow);
                    trend.Add((haClose > haOpen) ? true : false);
                }
                else
                {
                    open[open.Count - 1] = haOpen;
                    close[close.Count - 1] = haClose;
                    high[high.Count - 1] = haHigh;
                    low[low.Count - 1] = haLow;
                    trend[trend.Count - 1] = (haClose > haOpen) ? true : false;
                }

            }



        }



        void drawTrendLine(string id, Bars bar, int index, DateTime startTime, double startY, DateTime endTime, double endY, Color clr, bool showHL, int thickness)
        {

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

            Chart.DrawTrendLine(id + "line", startTime, startY, endTime, endY, clr, thickness);

            if (showHL)
            {
                Chart.DrawEllipse(id + "high", time, high, time, high, clr, 3);
                Chart.DrawEllipse(id + "low", time, low, time, low, clr, 3);

                Chart.DrawTrendLine(id + "verticle", time, high, time, low, clr, 1, LineStyle.DotsVeryRare);
                Chart.DrawTrendLine(id + "upperline", startTime, bar.HighPrices[index - 1], time, high, clr, 1, LineStyle.DotsVeryRare);
                Chart.DrawTrendLine(id + "lowerline", startTime, bar.LowPrices[index - 1], time, low, clr, 1, LineStyle.DotsVeryRare);
            }
        }









    }
}


ZuniSoft's avatar
ZuniSoft

Joined on 11.03.2019

  • Distribution: Paid
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: MultiTimeframe Trend EA.algo
  • Rating: 0
  • Installs: 960
Comments
Log in to add a comment.
No comments found.