Category Volatility  Published on 13/02/2022

Auto Draw Fibonacci

Description

Auto Draw Fibonacci on period of X Bar


v1 : Add custom colour


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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Autofibov1 : Indicator
    {
        [Parameter("Look Back Period ", DefaultValue = 100)]
        public int lookback { get; set; }

        [Parameter("Series Timeframe")]
        public TimeFrame tf { get; set; }


        [Parameter("Bullish Color", DefaultValue = "blue")]
        public string bulcolor { get; set; }


        [Parameter("Bearish Color", DefaultValue = "red")]
        public string bercolor { get; set; }

        private MarketSeries series1;


        protected override void Initialize()
        {
            // Initialize and create nested indicators
            series1 = MarketData.GetSeries(tf);

            OnTimer();
            Timer.Start(60);
        }

        protected override void OnTimer()
        {
            // Initialize and create nested indicators

            //find index
            var hidate = Time.Date;
            var lodate = Time.Date;
            var superhi = MarketSeries.Close.LastValue;
            var superlo = MarketSeries.Close.LastValue;
            var highval = series1.High;
            var loval = series1.Low;

            for (var i = 0; i < lookback; i++)
            {
                //find hi
                if (highval.Last(i) > superhi)
                {
                    superhi = highval.Last(i);
                    hidate = series1.OpenTime.Last(i);
                }

                //findlo
                if (loval.Last(i) < superlo)
                {
                    superlo = loval.Last(i);
                    lodate = series1.OpenTime.Last(i);
                }


                var bull = (hidate > lodate) ? true : false;
                var datechosen = (bull) ? lodate : hidate;

                //set value of line

                List<double> level = new List<double> 
                {
                    0.0,
                    23.6,
                    38.0,
                    50.0,
                    61.8,
                    100
                };


                var now = MarketSeries.OpenTime.LastValue;
                var distance = superhi - superlo;
//drawline 

                foreach (var lev in level)
                {
                    var dev = lev / 100 * distance;
                    var val = (bull) ? superhi - dev : superlo + dev;

                    Chart.DrawTrendLine(lev + "%", datechosen, val, now, val, (bull) ? bercolor : bulcolor, 1, LineStyle.Solid);
                    Chart.DrawText(lev + "% text", lev + "%", MarketSeries.OpenTime.Count + 1, val + 0.5 * Symbol.PipSize, (bull) ? bercolor : bulcolor);



                }






            }


        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...
        }
    }
}


fundspreader's avatar
fundspreader

Joined on 30.01.2017

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Autofibo v1.algo
  • Rating: 5
  • Installs: 7267
  • Modified: 13/02/2022 14:46
Comments
Log in to add a comment.
NY
nyalaeric · 3 months ago

Very useful tool especially the magnet component do not have to struggle with mouse movement to capture swing point precisely. Thanks

NOSHAKING_TRADER's avatar
NOSHAKING_TRADER · 4 months ago

Thank you for this 

JA
javid.pnd · 1 year ago

This is great ,could you please make v2 with more fibo lines and also with timeframe option .Thank you

LO
louisbrowne · 3 years ago

Jeepers your name suits you.

Thank you deeply!

YA
yalesonleite · 4 years ago

Olá, parabéns pelo seu trabalho...Por acaso teria algum de volume como weis wave...aqui não tem.rsrs abrações

fundspreader's avatar
fundspreader · 4 years ago

@velu130486

Thank you for your interest, 
and apology for lack of response since I don't have any notification on the comments.

Yeah, the indicator can be used for Cbot.

you can contact me at rony.sitepu@gmail.com
if you want to develop something out of it.


Best regards 
RKS

fundspreader's avatar
fundspreader · 5 years ago

Thank you..[meer987@gmail.com]

ME
meer987@gmail.com · 5 years ago

Absolutely amazing Autofibo indicator.

5 stars.

Kudos to the developer.