Category Other  Published on 20/08/2023

Pivot Point Officiel

An update for this algorithm is currently pending moderation. Please revisit this page shortly to access the algorithm's latest version.
Description

Pivot Point. 

I found a bug for May 2023 (Monthly Pivot), Maybe it's a data probleme.

Apart from that it seems to work very well.

Have fun, and for any collaboration, contact me !!!

On telegram : https://t.me/nimi012 (direct messaging)

On Discord: https://discord.gg/jNg7BSCh  (I advise you to come and see, Money management strategies and Signals Strategies !)

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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class PivotPointOfficiel3 : Indicator
    {
        [Parameter("Mode", DefaultValue = ModeType.Standard)]
        public ModeType Mode { get; set; }
        [Parameter("Time Frame", DefaultValue = "Daily")]
        public TimeFrame TF { get; set; }

        public enum ModeType
        {
            Standard,
            Fibonacci,
            FibonacciOpenClose,
            FibonacciHighLow,
            Camarilla,
            Woodie,
            DeMark
        }
        private Bars bars;
        private Bars bars2;
        private int indexBase;
        private int indexBase2;

        private IndicatorDataSeries High;
        private IndicatorDataSeries Low;

        private IndicatorDataSeries Open;
        private IndicatorDataSeries Close;

        public IndicatorDataSeries p, m, mh, ml, r1, r2, r3, r4, r5, r6, r7, r8, s1, s2, s3, s4, s5, s6, s7, s8;

        protected override void Initialize()
        {
            bars = MarketData.GetBars(TF);
            bars2 = MarketData.GetBars(TF);

            High = CreateDataSeries();
            Low = CreateDataSeries();
            Open = CreateDataSeries();
            Close = CreateDataSeries();

            p = CreateDataSeries();
            m = CreateDataSeries();
            mh = CreateDataSeries();
            ml = CreateDataSeries();
            r1 = CreateDataSeries();
            r2 = CreateDataSeries();
            r3 = CreateDataSeries();
            r4 = CreateDataSeries();
            r5 = CreateDataSeries();
            r6 = CreateDataSeries();
            r7 = CreateDataSeries();
            r8 = CreateDataSeries();
            s1 = CreateDataSeries();
            s2 = CreateDataSeries();
            s3 = CreateDataSeries();
            s4 = CreateDataSeries();
            s5 = CreateDataSeries();
            s6 = CreateDataSeries();
            s7 = CreateDataSeries();
            s8 = CreateDataSeries();
        }
        public override void Calculate(int index)
        {
            indexBase = bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.Last(1));
            indexBase2 = bars.OpenTimes.GetIndexByTime(Bars.OpenTimes.Last(0));

            High[index] = bars.HighPrices[indexBase - 1];
            Low[index] = bars.LowPrices[indexBase - 1];
            Open[index] = bars.OpenPrices[indexBase - 1];
            Close[index] = bars.ClosePrices[indexBase - 1];

            if (Mode == ModeType.Standard)
            {
                p[index - 1] = (High[index] + Low[index] + Close[index]) / 3;
                p[index] = p[index - 1];

                m[index - 1] = double.NaN;

                r1[index - 1] = 2 * p[index] - Low[index];
                r1[index] = r1[index - 1];
                s1[index - 1] = 2 * p[index] - High[index];
                s1[index] = s1[index - 1];

                r2[index - 1] = p[index] + High[index] - Low[index];
                r2[index] = r2[index - 1];
                s2[index - 1] = p[index] - High[index] + Low[index];
                s2[index] = s2[index - 1];

                r3[index - 1] = High[index] + 2 * (p[index] - Low[index]);
                r3[index - 1] = r3[index - 1];
                s3[index - 1] = Low[index] - 2 * (High[index] - p[index]);
                s3[index - 1] = s3[index - 1];

                r4[index - 1] = High[index] + 3 * (p[index] - Low[index]);
                r4[index - 1] = r4[index - 1];
                s4[index - 1] = Low[index] - 3 * (High[index] - p[index]);
                s4[index - 1] = s4[index - 1];

                r5[index - 1] = double.NaN;
                s5[index - 1] = double.NaN;

                r6[index - 1] = double.NaN;
                s6[index - 1] = double.NaN;

                r7[index - 1] = double.NaN;
                s7[index - 1] = double.NaN;

                r8[index - 1] = double.NaN;
                s8[index - 1] = double.NaN;
            }
            else if (Mode == ModeType.Woodie)
            {
                p[index - 1] = (High[index] + Low[index] + 2 * Close[index]) / 4;
                p[index] = p[index - 1];

                m[index - 1] = double.NaN;

                r1[index - 1] = 2 * p[index] - Low[index];
                s1[index - 1] = 2 * p[index] - High[index];

                r2[index - 1] = p[index] + High[index] - Low[index];
                s2[index - 1] = p[index] - High[index] + Low[index];

                r3[index - 1] = High[index] + 2 * (p[index] - Low[index]);
                s3[index - 1] = Low[index] - 2 * (High[index] - p[index]);

                r4[index - 1] = High[index] + 3 * (p[index] - Low[index]);
                s4[index - 1] = Low[index] - 3 * (High[index] - p[index]);

                r5[index - 1] = double.NaN;
                s5[index - 1] = double.NaN;

                r6[index - 1] = double.NaN;
                s6[index - 1] = double.NaN;

                r7[index - 1] = double.NaN;
                s7[index - 1] = double.NaN;

                r8[index - 1] = double.NaN;
                s8[index - 1] = double.NaN;
            }
            else if (Mode == ModeType.Fibonacci)
            {
                m[index - 1] = double.NaN;
                p[index - 1] = (High[index] + Low[index] + Close[index]) / 3.0;
                p[index] = p[index - 1];

                r1[index - 1] = p[index] + (High[index] - Low[index]) * 0.382;
                s1[index - 1] = p[index] - (High[index] - Low[index]) * 0.382;

                r2[index - 1] = p[index] + (High[index] - Low[index]) * 0.618;
                s2[index - 1] = p[index] - (High[index] - Low[index]) * 0.618;

                r3[index - 1] = p[index] + (High[index] - Low[index]) * 0.886;
                s3[index - 1] = p[index] - (High[index] - Low[index]) * 0.886;

                r3[index - 1] = p[index] + (High[index] - Low[index]) * 1.0;
                s3[index - 1] = p[index] - (High[index] - Low[index]) * 1.0;

                r4[index - 1] = p[index] + (High[index] - Low[index]) * 1.27;
                s4[index - 1] = p[index] - (High[index] - Low[index]) * 1.27;

                r5[index - 1] = p[index] + (High[index] - Low[index]) * 1.618;
                s5[index - 1] = p[index] - (High[index] - Low[index]) * 1.618;

                r6[index - 1] = p[index] + (High[index] - Low[index]) * 2.0;
                s6[index - 1] = p[index] - (High[index] - Low[index]) * 2.0;

                r7[index - 1] = p[index] + (High[index] - Low[index]) * 2.618;
                s7[index - 1] = p[index] - (High[index] - Low[index]) * 2.618;

                r8[index - 1] = double.NaN;
                s8[index - 1] = double.NaN;
            }
            else if (Mode == ModeType.FibonacciOpenClose)
            {
                if (Open[index] > Close[index])
                {
                    m[index - 1] = double.NaN;
                    p[index - 1] = Close[index];

                    r1[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.114);
                    s1[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.114);

                    r2[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.236);
                    s2[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.236);

                    r3[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.382);
                    s3[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.382);

                    r4[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.5);
                    s4[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.5);

                    r5[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.618);
                    s5[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.618);

                    r6[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.707);
                    s6[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.707);

                    r7[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.886);
                    s7[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.886);

                    r8[index - 1] = Close[index] + (Open[index] - Close[index]);
                    s8[index - 1] = Close[index] - (Open[index] - Close[index]);
                }
                else if (Open[index] < Close[index])
                {
                    m[index - 1] = double.NaN;
                    p[index - 1] = Close[index];

                    s1[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.114);
                    r1[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.114);

                    s2[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.236);
                    r2[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.236);

                    s3[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.382);
                    r3[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.382);

                    s4[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.5);
                    r4[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.5);

                    s5[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.618);
                    r5[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.618);

                    s6[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.707);
                    r6[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.707);

                    s7[index - 1] = Close[index] + ((Open[index] - Close[index]) * 0.886);
                    r7[index - 1] = Close[index] - ((Open[index] - Close[index]) * 0.886);

                    s8[index - 1] = Close[index] + (Open[index] - Close[index]);
                    r8[index - 1] = Close[index] - (Open[index] - Close[index]);
                }
            }
            else if (Mode == ModeType.FibonacciHighLow)
            {
                if (Open[index] < Close[index])
                {
                    m[index - 1] = double.NaN;
                    p[index - 1] = High[index];

                    r1[index - 1] = High[index] + ((High[index] - Low[index]) * 0.114);
                    s1[index - 1] = High[index] - ((High[index] - Low[index]) * 0.114);

                    r2[index - 1] = High[index] + ((High[index] - Low[index]) * 0.236);
                    s2[index - 1] = High[index] - ((High[index] - Low[index]) * 0.236);

                    r3[index - 1] = High[index] + ((High[index] - Low[index]) * 0.382);
                    s3[index - 1] = High[index] - ((High[index] - Low[index]) * 0.382);

                    r4[index - 1] = High[index] + ((High[index] - Low[index]) * 0.5);
                    s4[index - 1] = High[index] - ((High[index] - Low[index]) * 0.5);

                    r5[index - 1] = High[index] + ((High[index] - Low[index]) * 0.618);
                    s5[index - 1] = High[index] - ((High[index] - Low[index]) * 0.618);

                    r6[index - 1] = High[index] + ((High[index] - Low[index]) * 0.707);
                    s6[index - 1] = High[index] - ((High[index] - Low[index]) * 0.707);

                    r7[index - 1] = High[index] + ((High[index] - Low[index]) * 0.886);
                    s7[index - 1] = High[index] - ((High[index] - Low[index]) * 0.886);

                    r8[index - 1] = High[index] + (High[index] - Low[index]);
                    s8[index - 1] = High[index] - (High[index] - Low[index]);
                }
                else if (Open[index] > Close[index])
                {
                    m[index - 1] = double.NaN;
                    p[index - 1] = Low[index];

                    r1[index - 1] = Low[index] - ((Low[index] - High[index]) * 0.114);
                    s1[index - 1] = Low[index] + ((Low[index] - High[index]) * 0.114);

                    r2[index - 1] = Low[index] - ((Low[index] - High[index]) * 0.236);
                    s2[index - 1] = Low[index] + ((Low[index] - High[index]) * 0.236);

                    r3[index - 1] = Low[index] - ((Low[index] - High[index]) * 0.382);
                    s3[index - 1] = Low[index] + ((Low[index] - High[index]) * 0.382);

                    r4[index - 1] = Low[index] - ((Low[index] - High[index]) * 0.5);
                    s4[index - 1] = Low[index] + ((Low[index] - High[index]) * 0.5);

                    r5[index - 1] = Low[index] - ((Low[index] - High[index]) * 0.618);
                    s5[index - 1] = Low[index] + ((Low[index] - High[index]) * 0.618);

                    r6[index - 1] = Low[index] - ((Low[index] - High[index]) * 0.707);
                    s6[index - 1] = Low[index] + ((Low[index] - High[index]) * 0.707);

                    r7[index - 1] = Low[index] - ((Low[index] - High[index]) * 0.886);
                    s7[index - 1] = Low[index] + ((Low[index] - High[index]) * 0.886);

                    r8[index - 1] = Low[index] - (Low[index] - High[index]);
                    s8[index - 1] = Low[index] + (Low[index] - High[index]);
                }
            }
            else if (Mode == ModeType.Camarilla)
            {
                p[index - 1] = (High[index] + Low[index] + Close[index]) / 3.0;

                m[index - 1] = Close[index];

                ml[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1 / 24;
                mh[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1 / 24;

                r1[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1 / 12.0;
                s1[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1 / 12.0;

                r2[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1 / 6.0;
                s2[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1 / 6.0;

                r3[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1 / 4.0;
                s3[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1 / 4.0;

                r4[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1 / 2.0;
                s4[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1 / 2.0;

                r5[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1 * 3.0 / 4.0;
                s5[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1 * 3.0 / 4.0;

                r6[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1;
                s6[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1;

                r7[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1 * 5.0 / 4.0;
                s7[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1 * 5.0 / 4.0;

                r8[index - 1] = Close[index] + (High[index] - Low[index]) * 1.1 * 3.0 / 2.0;
                s8[index - 1] = Close[index] - (High[index] - Low[index]) * 1.1 * 3.0 / 2.0;
            }
            else if (Mode == ModeType.DeMark)
            {
                double open = Bars.OpenPrices[index - 1];
                double X = Close[index] < open ? (High[index] + 2.0 * Low[index] + Close[index]) : Close[index] > open ? (2.0 * High[index] + Low[index] + Close[index]) : (High[index] + Low[index] + 2.0 * Close[index]);

                m[index - 1] = double.NaN;

                p[index - 1] = X / 4.0;

                r1[index - 1] = X / 2.0 - Low[index];
                s1[index - 1] = X / 2.0 - High[index];

                r2[index - 1] = double.NaN;
                s2[index - 1] = double.NaN;

                r3[index - 1] = double.NaN;
                s3[index - 1] = double.NaN;

                r4[index - 1] = double.NaN;
                s4[index - 1] = double.NaN;

                r5[index - 1] = double.NaN;
                s5[index - 1] = double.NaN;

                r6[index - 1] = double.NaN;
                s6[index - 1] = double.NaN;

                r7[index - 1] = double.NaN;
                s7[index - 1] = double.NaN;

                r8[index - 1] = double.NaN;
                s8[index - 1] = double.NaN;
            }
            m[index] = m[index - 1];
            p[index] = p[index - 1];

            r1[index] = r1[index - 1];
            s1[index] = s1[index - 1];

            r2[index] = r2[index - 1];
            s2[index] = s2[index - 1];

            r3[index] = r3[index - 1];
            s3[index] = s3[index - 1];

            r4[index] = r4[index - 1];
            s4[index] = s4[index - 1];

            r5[index] = r5[index - 1];
            s5[index] = s5[index - 1];

            r6[index] = r6[index - 1];
            s6[index] = s6[index - 1];

            r7[index] = r7[index - 1];
            s7[index] = s7[index - 1];

            r8[index] = r8[index - 1];
            s8[index] = s8[index - 1];

            if (High[index] != High[index - 1] && !double.IsNaN(r1[index]))
            {


                // Line Pivot 
                if (!double.IsNaN(m[index - 1]))
                    Chart.DrawTrendLine("m " + index, Bars.OpenTimes[index - 1], m[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], m[index - 1], "6CFFFFFF", 1, LineStyle.LinesDots);

                if (!double.IsNaN(p[index - 1]))
                    Chart.DrawTrendLine("p " + index, Bars.OpenTimes[index - 1], p[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], p[index - 1], "7702AFF1", 1, LineStyle.LinesDots);
                if (!double.IsNaN(mh[index - 1]))
                    Chart.DrawTrendLine("mh " + index, Bars.OpenTimes[index - 1], mh[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], mh[index - 1], "8EFFA500", 1, LineStyle.LinesDots);

                if (!double.IsNaN(r1[index - 1]))
                    Chart.DrawTrendLine("r1 " + index, Bars.OpenTimes[index - 1], r1[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], r1[index - 1], "66008000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(r2[index - 1]))
                    Chart.DrawTrendLine("r2 " + index, Bars.OpenTimes[index - 1], r2[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], r2[index - 1], "66008000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(r3[index - 1]))
                    Chart.DrawTrendLine("r3 " + index, Bars.OpenTimes[index - 1], r3[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], r3[index - 1], "66008000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(r4[index - 1]))
                    Chart.DrawTrendLine("r4 " + index, Bars.OpenTimes[index - 1], r4[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], r4[index - 1], "66008000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(r5[index - 1]))
                    Chart.DrawTrendLine("r5 " + index, Bars.OpenTimes[index - 1], r5[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], r5[index - 1], "66008000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(r6[index - 1]))
                    Chart.DrawTrendLine("r6 " + index, Bars.OpenTimes[index - 1], r6[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], r6[index - 1], "66008000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(r7[index - 1]))
                    Chart.DrawTrendLine("r7 " + index, Bars.OpenTimes[index - 1], r7[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], r7[index - 1], "66008000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(r8[index - 1]))
                    Chart.DrawTrendLine("r8 " + index, Bars.OpenTimes[index - 1], r8[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], r8[index - 1], "66008000", 1, LineStyle.LinesDots);

                if (!double.IsNaN(ml[index - 1]))
                    Chart.DrawTrendLine("ml " + index, Bars.OpenTimes[index - 1], ml[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], ml[index - 1], "8EFFA500", 1, LineStyle.LinesDots);
                if (!double.IsNaN(s1[index - 1]))
                    Chart.DrawTrendLine("s1 " + index, Bars.OpenTimes[index - 1], s1[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], s1[index - 1], "47FF0000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(s2[index - 1]))
                    Chart.DrawTrendLine("s2 " + index, Bars.OpenTimes[index - 1], s2[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], s2[index - 1], "47FF0000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(s3[index - 1]))
                    Chart.DrawTrendLine("s3 " + index, Bars.OpenTimes[index - 1], s3[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], s3[index - 1], "47FF0000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(s4[index - 1]))
                    Chart.DrawTrendLine("s4 " + index, Bars.OpenTimes[index - 1], s4[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], s4[index - 1], "47FF0000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(s5[index - 1]))
                    Chart.DrawTrendLine("s5 " + index, Bars.OpenTimes[index - 1], s5[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], s5[index - 1], "47FF0000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(s6[index - 1]))
                    Chart.DrawTrendLine("s6 " + index, Bars.OpenTimes[index - 1], s6[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], s6[index - 1], "47FF0000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(s7[index - 1]))
                    Chart.DrawTrendLine("s7 " + index, Bars.OpenTimes[index - 1], s7[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], s7[index - 1], "47FF0000", 1, LineStyle.LinesDots);
                if (!double.IsNaN(s8[index - 1]))
                    Chart.DrawTrendLine("s8 " + index, Bars.OpenTimes[index - 1], s8[index - 1], bars2.OpenTimes[indexBase2 + 1] < Bars.OpenTimes[index - 1] ? GetEndIndex() : bars2.OpenTimes[indexBase2 + 1], s8[index - 1], "47FF0000", 1, LineStyle.LinesDots);

                // Name Pivot

                if (!double.IsNaN(m[index - 1]))
                    Chart.DrawText("M " + index, "M", index - 1, m[index - 1], "Gray");
                if (!double.IsNaN(p[index - 1]))
                    Chart.DrawText("P " + index, "P", index - 1, p[index - 1], "7702AFF1");

                if (!double.IsNaN(r1[index - 1]))
                    Chart.DrawText("Lr1 " + index, "R1", index - 1, r1[index - 1], "9D008000");
                if (!double.IsNaN(r2[index - 1]))
                    Chart.DrawText("Lr2 " + index, "R2", index - 1, r2[index - 1], "9D008000");
                if (!double.IsNaN(r3[index - 1]))
                    Chart.DrawText("Lr3 " + index, "R3", index - 1, r3[index - 1], "9D008000");
                if (!double.IsNaN(r4[index - 1]))
                    Chart.DrawText("Lr4 " + index, "R4", index - 1, r4[index - 1], "9D008000");
                if (!double.IsNaN(r5[index - 1]))
                    Chart.DrawText("Lr5 " + index, "R5", index - 1, r5[index - 1], "9D008000");
                if (!double.IsNaN(r6[index - 1]))
                    Chart.DrawText("Lr6 " + index, "R6", index - 1, r6[index - 1], "9D008000");
                if (!double.IsNaN(r7[index - 1]))
                    Chart.DrawText("Lr7 " + index, "R7", index - 1, r7[index - 1], "9D008000");
                if (!double.IsNaN(r8[index - 1]))
                    Chart.DrawText("Lr8 " + index, "R8", index - 1, r8[index - 1], "9D008000");

                if (!double.IsNaN(s1[index - 1]))
                    Chart.DrawText("Ls1 " + index, "S1", index - 1, s1[index - 1], "6DFF0000");
                if (!double.IsNaN(s2[index - 1]))
                    Chart.DrawText("Ls2 " + index, "S2", index - 1, s2[index - 1], "6DFF0000");
                if (!double.IsNaN(s3[index - 1]))
                    Chart.DrawText("Ls3 " + index, "S3", index - 1, s3[index - 1], "6DFF0000");
                if (!double.IsNaN(s4[index - 1]))
                    Chart.DrawText("Ls4 " + index, "S4", index - 1, s4[index - 1], "6DFF0000");
                if (!double.IsNaN(s5[index - 1]))
                    Chart.DrawText("Ls5 " + index, "S5", index - 1, s5[index - 1], "6DFF0000");
                if (!double.IsNaN(s6[index - 1]))
                    Chart.DrawText("Ls6 " + index, "S6", index - 1, s6[index - 1], "6DFF0000");
                if (!double.IsNaN(s7[index - 1]))
                    Chart.DrawText("Ls7 " + index, "S7", index - 1, s7[index - 1], "6DFF0000");
                if (!double.IsNaN(s8[index - 1]))
                    Chart.DrawText("Ls8 " + index, "S8", index - 1, s8[index - 1], "6DFF0000");
            }
        }
        private DateTime GetEndIndex()
        {

            /// Tf bars ++
            if (TF == TimeFrame.Minute)
                return Bars.OpenTimes.Last(1).AddMinutes(1);
            else if (TF == TimeFrame.Minute5)
                return Bars.OpenTimes.Last(1).AddMinutes(1);
            else if (TF == TimeFrame.Minute10)
                return Bars.OpenTimes.Last(1).AddMinutes(10);
            else if (TF == TimeFrame.Minute15)
                return Bars.OpenTimes.Last(1).AddMinutes(15);
            else if (TF == TimeFrame.Minute20)
                return Bars.OpenTimes.Last(1).AddMinutes(20);
            else if (TF == TimeFrame.Minute30)
                return Bars.OpenTimes.Last(1).AddMinutes(30);

            else if (TF == TimeFrame.Hour)
                return Bars.OpenTimes.Last(1).AddHours(1);
            else if (TF == TimeFrame.Hour2)
                return Bars.OpenTimes.Last(1).AddHours(2);
            else if (TF == TimeFrame.Hour3)
                return Bars.OpenTimes.Last(1).AddHours(3);
            else if (TF == TimeFrame.Hour4)
                return Bars.OpenTimes.Last(1).AddHours(4);
            else if (TF == TimeFrame.Hour6)
                return Bars.OpenTimes.Last(1).AddHours(6);
            else if (TF == TimeFrame.Hour8)
                return Bars.OpenTimes.Last(1).AddHours(8);

            else if (TF == TimeFrame.Daily)
                return Bars.OpenTimes.Last(1).AddDays(1);
            else if (TF == TimeFrame.Day2)
                return Bars.OpenTimes.Last(1).AddDays(2);
            else if (TF == TimeFrame.Day3)
                return Bars.OpenTimes.Last(1).AddDays(3);

            else if (TF == TimeFrame.Weekly)
                return Bars.OpenTimes.Last(1).AddDays(5);

            else if (TF == TimeFrame.Monthly)
                return Bars.OpenTimes.Last(1).AddMonths(1);

            else
                return Bars.OpenTimes.Last(1).AddDays(1); ;
        }
    }
}



YE
YesOrNot

Joined on 10.10.2022 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Pivot Point Officiel (3).algo
  • Rating: 0
  • Installs: 720
  • Modified: 20/08/2023 20:14
Comments
Log in to add a comment.
AD
AdolphDute · 9 months ago

i install, but nothing in my chart.