Simple indicator modification (pivot 2 show value)

Created at 23 Nov 2021
jani's avatar

jani

Joined 05.04.2019

Status

Closed


Budget

50.00 EUR


Payment Method

via  Freelancer

Job Description

I have a standard simplified pivot indicator that draws pivot lines on the chart. I would like to call these indicator values from a cBot, so I would need to have the indicator to output values for the current pivot as well as the past pivots ( I already programmed output in the yellow line that is drawing the current pivot) .
I want new Pivot lines redrawn as the daily bar opens (daily bar closes at 21:00 UTC). 5 pivots in the past is enough.
 Please see the attached video for reference. https://vimeo.com/649040540

When:
"DailyCandleChange = MarketData.GetSeries(TimeFrame.Daily).Close.Last(1);"
I live trading DailyCandleChange will calculate bar closing at 21:00 UTC (New York close), which is fine. So for this reason new pivots are always drawn after 21:00 UTC.

Ps.  think the issue is simply just to add a FOR-loop in "public override void Calculate(int index)..." that recalculates after the daily bar is redrawn, however, I cannot figure out how to write this. For someone who knows what he is doing this should not be more than a 15-minute job...

 

I can pay Freelancer or PayPal or some crypto that has reasonable transfer fees

 

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


namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Cyf_Pivots : Indicator
    {

        private MarketSeries dailyMarketSeries;

        double dayPivot;

        int market_Bars;


        [Parameter(DefaultValue = 5, MinValue = 1)]
        public int Lookback { get; set; }


        [Parameter(DefaultValue = 15, MinValue = -300, Step = 5)]
        public int LabelOffSet { get; set; }

        [Parameter(DefaultValue = 3, MinValue = -5, Step = 1)]
        public int TimeOffSet { get; set; }

        [Output("Pivot", LineColor = "Yellow", PlotType = PlotType.DiscontinuousLine)]
        public IndicatorDataSeries Pivot { get; set; }


        private void drawPivotLevel(int dayRank)
        {

            if (dailyMarketSeries == null)
                dailyMarketSeries = MarketData.GetSeries(TimeFrame.Daily);

            dayPivot = (dailyMarketSeries.High.Last(dayRank) + dailyMarketSeries.Low.Last(dayRank) + dailyMarketSeries.Close.Last(dayRank)) / 3;
            DateTime Start = dailyMarketSeries.OpenTime.Last(dayRank - 1).Date;
            DateTime today = Start.AddDays(1);
            DateTime today2 = Start.AddHours(24 - TimeOffSet);
            DateTime tomorrow = Start.AddDays(2);
            DateTime tomorrow2 = Start.AddHours(48 - TimeOffSet);


            Chart.DrawTrendLine("hLine" + dayRank, today2, dayPivot, tomorrow2, dayPivot, Color.CornflowerBlue, 1, LineStyle.Lines);
            Chart.DrawText("PV_Label" + dayRank, "PV", today2.AddMinutes(LabelOffSet), dayPivot, Color.CornflowerBlue);


        }

        private void OutputPivotLevel(int day)
        {

            double _pivot = (MarketData.GetSeries(TimeFrame.Daily).High.Last(day) + MarketData.GetSeries(TimeFrame.Daily).Low.Last(day) + MarketData.GetSeries(TimeFrame.Daily).Close.Last(day)) / 3;

        }


        protected override void Initialize()
        {

            for (int i = Lookback; i > 0; i--)
                drawPivotLevel(i);

            market_Bars = dailyMarketSeries.Open.Count;
        }


        public override void Calculate(int index)
        {

            Pivot[index] = (MarketData.GetSeries(TimeFrame.Daily).High.Last(1) + MarketData.GetSeries(TimeFrame.Daily).Low.Last(1) + MarketData.GetSeries(TimeFrame.Daily).Close.Last(1)) / 3;


            if (dailyMarketSeries.Open.Count - market_Bars == 1)
            {
                market_Bars += 1;
                Initialize();
            }
            else
                return;



        }
    }
}


 

Comments
JosephTradingbot's avatar
JosephTradingbot · 2 years ago

Hi, I can do it for you.
with several years of experience in programming and forex analysis and trading.

Telegram: @iamjosepe

WhatsApp: (+98)930 462 2633

Email: joseph.tradingbot@gmail.com