Ultimate Renko indicator paid

by arturzas in category Trend at 14/10/2020
Description

Very flexible renko indicator for cTrader offering presets for the most popular renko chart types:

  • Renko
  • Median Renko
  • PointO
  • Turbo Renko
  • Hybrid Renko

Turbo renko and median renko on cTrader

This is an updated version of the Median Renko Ultimate indicator offered from https://ctrader.com/algos/indicators/show/1332 and it is a FREE update for all of the licensed users of the MedianRenko indicator for cTrader.

The indicator lets you freely design renko charts tailored to your specific needs by tweaking the 4 variables presented below and specifying whether you want to see the wicks or not.

This is a 14-day trial version.  Lifetime license can be purchased >> here << 

The latest version always available on OneDrive


IMPORTANT: The renko chart displayed as an overlay on the main chart so, you may want to change the chart properties to "line chart" and the "Bear Outline" color to black for better clarity of displayed bars.


 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
using cT_UltimateRenkoEngine;

namespace cAlgo
{
    [Indicator(IsOverlay = true, AutoRescale = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class UltimateRenko : Indicator
    {
        [Parameter("Bar Size (Pips)", DefaultValue = 10, MinValue = 0.1, Step = 1)]
        public double BarSizePips { get; set; }

        [Parameter("Renko mode preset", DefaultValue = RENKO_PRESET.None)]
        public RENKO_PRESET Preset { get; set; }

        [Parameter("Open offset % (0 to ...)", DefaultValue = 50, MinValue = 0, MaxValue = Int32.MaxValue, Step = 1)]
        public int OpenOffset { get; set; }

        [Parameter("Reversal Open offset % (0 to ...)", DefaultValue = 50, MinValue = 0, MaxValue = Int32.MaxValue, Step = 1)]
        public int ReversalOpenOffset { get; set; }

        [Parameter("Reversal bar size % (0 to ...)", DefaultValue = 150, MinValue = 0, MaxValue = Int32.MaxValue, Step = 1)]
        public int ReversalBarSize { get; set; }

        [Parameter("Show wicks", DefaultValue = true)]
        public bool ShowWicks { get; set; }

        [Parameter("Maximum Bars", DefaultValue = 300, MinValue = 1)]
        public int BricksToShow { get; set; }

        [Parameter("Reset Open on new trading day", DefaultValue = false)]
        public bool ResetOpenOnNewTradingDay { get; set; }

        [Parameter("Truncate trailing digits on the first renko", DefaultValue = false)]
        public bool ApplyOffsetToFirstBar { get; set; }

        [Parameter("Number of digits to truncate", DefaultValue = 1, MinValue = 0)]
        public int OffsetValue { get; set; }

        [Parameter("Bullish Bar Color", DefaultValue = "SeaGreen")]
        public string ColorBull { get; set; }

        [Parameter("Bearish Bar Color", DefaultValue = "Tomato")]
        public string ColorBear { get; set; }

        [Output("Open", LineColor = "DimGray", Thickness = 0, PlotType = PlotType.Points)]
        public IndicatorDataSeries Open { get; set; }

        [Output("High", LineColor = "DimGray", Thickness = 0, PlotType = PlotType.Points)]
        public IndicatorDataSeries High { get; set; }

        [Output("Low", LineColor = "DimGray", Thickness = 0, PlotType = PlotType.Points)]
        public IndicatorDataSeries Low { get; set; }

        [Output("Close", LineColor = "DimGray", Thickness = 0, PlotType = PlotType.Points)]
        public IndicatorDataSeries Close { get; set; }

        private UltimateRenkoCore core = null;
        private bool coreOK = true;

        private DateTime lastTime;

        private bool appliedOffset = false;

        private T_OLHCV pOLHCV;
        private T_OLHCV OLHCV;
        private T_OLHCV mOLHCV;
        private T_OLHCV cOLHCV;
        private T_OLHCV memRates;

        private double pOpen;
        private double pRevOpen;
        private double pRevSize;

        private readonly List<T_OLHCV> bars = new List<T_OLHCV>();
        private double barSize;
        private Color colorBull, colorBear;

        protected override void Initialize()
        {
            core = new UltimateRenkoCore();
            coreOK = core.StatusCheck();

            barSize = BarSizePips * Symbol.PipSize;

            if (Preset == RENKO_PRESET.None)
            {
                pOpen = Math.Abs(OpenOffset * 0.01);
                pRevOpen = Math.Abs(ReversalOpenOffset * 0.01);
                pRevSize = Math.Max(0.01, Math.Abs(ReversalBarSize * 0.01));
            }
            else
            {
                Presets.Get(Preset, ref pOpen, ref pRevOpen, ref pRevSize);
            }

            lastTime = new DateTime();
            lastTime = Bars.OpenTimes[Bars.ClosePrices.Count - 1];

            pOLHCV = new T_OLHCV();
            OLHCV = new T_OLHCV();
            mOLHCV = new T_OLHCV();
            cOLHCV = new T_OLHCV();
            memRates = new T_OLHCV();

            colorBull = Color.FromName(ColorBull);
            colorBear = Color.FromName(ColorBear);

            appliedOffset = false;
        }

        private bool NewBar(int index)
        {
            if (lastTime != Bars.OpenTimes[index])
            {
                lastTime = Bars.OpenTimes[index];
                return true;
            }

            return false;
        }

        private static int cc = 0;
        private void PushBars(T_OLHCV bar, bool display)
        {
            int count = bars.Count();

            var newBar = new T_OLHCV();
            newBar.Copy(bar);
            newBar.Index = cc++;

            bars.Insert(0, newBar);
            count++;

            if (display)
            {
                ShitBars();
            }

            if (count > BricksToShow)
            {
                if (display)
                {
                    for (int i = BricksToShow - 1; i < count; i++)
                    {
                        Chart.RemoveObject("mr_Wick_" + bars[i].Index);
                        Chart.RemoveObject("mr_Bar_" + bars[i].Index);
                    }
                }

                bars.RemoveRange(BricksToShow, count - BricksToShow);

                Open[count - BricksToShow] = double.NaN;
                High[count - BricksToShow] = double.NaN;
                Low[count - BricksToShow] = double.NaN;
                Close[count - BricksToShow] = double.NaN;
            }

        }

        private void ShitBars()
        {
            int count = bars.Count;
            int ix = Bars.ClosePrices.Count - 2;

            for (int i = 0; i < count && i < BricksToShow; i++)
            {
                var candleColor = (bars[i].Close > bars[i].Open) ? colorBull : colorBear;

                Chart.DrawTrendLine("mr_Wick_" + bars[i].Index, ix, bars[i].High, ix, bars[i].Low, candleColor, 1, LineStyle.Solid);
                Chart.DrawTrendLine("mr_Bar_" + bars[i].Index, ix, bars[i].Close, ix, bars[i].Open, candleColor, 5, LineStyle.Solid);

                Open[ix] = bars[i].Open;
                High[ix] = bars[i].High;
                Low[ix] = bars[i].Low;
                Close[ix] = bars[i].Close;

                ix--;
            }
        }

        private void UpdateLastBar(int ix)
        {
            var candleColor = (memRates.Close > memRates.Open) ? colorBull : colorBear;

            Chart.DrawTrendLine("mr_Wick_Live", ix, memRates.High, ix, memRates.Low, candleColor, 1, LineStyle.Solid);
            Chart.DrawTrendLine("mr_Bar_Live", ix, memRates.Close, ix, memRates.Open, candleColor, 5, LineStyle.Solid);

            Open[ix] = memRates.Open;
            High[ix] = memRates.High;
            Low[ix] = memRates.Low;
            Close[ix] = memRates.Close;

        }

        public override void Calculate(int index)
        {
            if (ResetOpenOnNewTradingDay)
            {
                if (IsNewSession(Bars.OpenTimes[(index > 0) ? (index - 1) : index], Bars.OpenTimes[index]))
                {
                    cOLHCV.Clear();
                    mOLHCV.Clear();
                    pOLHCV.Clear();
                    memRates.Copy(mOLHCV);
                }
            }

            if (IsLastBar)
            {
                if (!coreOK)
                {
                    Chart.DrawStaticText("TrialOverMsg", "UltimateRenko - Trial period ended. Please purchase a license at www.az-invest.eu", VerticalAlignment.Center, API.HorizontalAlignment.Center, Color.White);
                    return;
                }

                if (NewBar(index))
                {
                    ShitBars();

                    Open[index - BricksToShow - 1] = double.NaN;
                    High[index - BricksToShow - 1] = double.NaN;
                    Low[index - BricksToShow - 1] = double.NaN;
                    Close[index - BricksToShow - 1] = double.NaN;
                }

                OLHCV.Open = Bars.ClosePrices[index];
                OLHCV.Low = Bars.ClosePrices[index];
                OLHCV.High = Bars.ClosePrices[index];
                OLHCV.Close = Bars.ClosePrices[index];
                OLHCV.OpenTime = Bars.OpenTimes[index];
                OLHCV.TickVolume = 1;


                ProcessMarketData(OLHCV);
                UpdateLastBar(index);
            }
            else
            {

                OLHCV.Open = Bars.OpenPrices[index];
                OLHCV.Low = Bars.LowPrices[index];
                OLHCV.High = Bars.HighPrices[index];
                OLHCV.Close = Bars.ClosePrices[index];
                OLHCV.OpenTime = Bars.OpenTimes[index];
                OLHCV.TickVolume = Bars.TickVolumes[index];

                if (ApplyOffsetToFirstBar && !appliedOffset)
                {
                    OLHCV.Open = Math.Round(OLHCV.Open, (Symbol.Digits - OffsetValue), MidpointRounding.ToEven);
                    appliedOffset = true;
                }

                ProcessMarketData(OLHCV);

                if (IsLastBar)
                    UpdateLastBar(index);
            }
        }

        private void ProcessMarketData(T_OLHCV ___OLHCV)
        {
            int rb_return = core.ProcessUltimateRenko(barSize, pOpen, pRevSize, pRevOpen, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 1);
            while (true)
            {
                if ((rb_return >= 1) && (rb_return <= 4))
                {
                    PushBars(cOLHCV, IsLastBar);
                    memRates.Copy(mOLHCV);
                    OLHCV.Copy(memRates);

                    cOLHCV.Clear();
                    mOLHCV.Clear();

                    rb_return = core.ProcessUltimateRenko(barSize, pOpen, pRevSize, pRevOpen, ___OLHCV, ref pOLHCV, ref mOLHCV, ref cOLHCV, 0);
                    continue;

                }
                else if (rb_return == 10)
                {
                    memRates.Copy(mOLHCV);
                    break;
                }
                else if (rb_return == -1)
                {
                    return;
                }
                else
                {
                    throw new Exception("Unhandled return value = " + rb_return);
                }
            }

            if (IsLastBar)
            {
                ShitBars();
            }
        }

        private bool IsNewSession(DateTime prevTime, DateTime currTime)
        {
            if (prevTime.DayOfWeek != currTime.DayOfWeek)
                return true;
            else
                return false;
        }
    }
}

Comments
0