Change the start hour of day

Created at 24 Jan 2019, 16:02
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
PO

pozhy

Joined 03.04.2018

Change the start hour of day
24 Jan 2019, 16:02


Hi, This indicator is written by one of the members. I wonder if we can change the beginning hour of each day by TimeShift parameter or another input that indicates start hour is 8 am for example

 

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 CustomTFCandlesticks : Indicator

    {

        [Parameter()]

        public TimeFrame Timeframe { get; set; }

         [Parameter("Time Shift ", DefaultValue = 0)]
        public int TimeShift { get; set; }

        [Parameter("Thickness", DefaultValue = 1)]

        public double Thickness { get; set; }

 

        private MarketSeries tf;

 

        protected override void Initialize()

        {

            tf = MarketData.GetSeries(Timeframe);

        }

 

        public override void Calculate(int index)

        {

            int idx1 = tf.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);

            int idx2 = MarketSeries.OpenTime.GetIndexByTime(tf.OpenTime[idx1]);

            int idx3 = idx2 + (index - idx2) / 2;

 

            double open = tf.Open[idx1];

            double high = tf.High[idx1];

            double low = tf.Low[idx1];

            double close = tf.Close[idx1];

 

            var color = open < close ? Colors.Green : Colors.Red;

 

            ChartObjects.DrawLine("top" + idx1, idx2, close, index, close, color, Thickness);

            ChartObjects.DrawLine("bottom" + idx1, idx2, open, index, open, color, Thickness);

            ChartObjects.DrawLine("left" + idx1, idx2, open, idx2, close, color, Thickness);

            ChartObjects.DrawLine("right" + idx1, index, open, index, close, color, Thickness)

 

        }

    }

}


@pozhy
Replies

pozhy
11 Feb 2019, 03:26

RE:

pozhy said:

Hi, This indicator is written by one of the members. I wonder if we can change the beginning hour of each day by TimeShift parameter or another input that indicates start hour is 8 am for example

 

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 CustomTFCandlesticks : Indicator

    {

        [Parameter()]

        public TimeFrame Timeframe { get; set; }

         [Parameter("Time Shift ", DefaultValue = 0)]
        public int TimeShift { get; set; }

        [Parameter("Thickness", DefaultValue = 1)]

        public double Thickness { get; set; }

 

        private MarketSeries tf;

 

        protected override void Initialize()

        {

            tf = MarketData.GetSeries(Timeframe);

        }

 

        public override void Calculate(int index)

        {

            int idx1 = tf.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);

            int idx2 = MarketSeries.OpenTime.GetIndexByTime(tf.OpenTime[idx1]);

            int idx3 = idx2 + (index - idx2) / 2;

 

            double open = tf.Open[idx1];

            double high = tf.High[idx1];

            double low = tf.Low[idx1];

            double close = tf.Close[idx1];

 

            var color = open < close ? Colors.Green : Colors.Red;

 

            ChartObjects.DrawLine("top" + idx1, idx2, close, index, close, color, Thickness);

            ChartObjects.DrawLine("bottom" + idx1, idx2, open, index, open, color, Thickness);

            ChartObjects.DrawLine("left" + idx1, idx2, open, idx2, close, color, Thickness);

            ChartObjects.DrawLine("right" + idx1, index, open, index, close, color, Thickness)

 

        }

    }

}

does anyone have an Idea, for example, I want to start day based on New York


@pozhy

PanagiotisCharalampous
11 Feb 2019, 10:41

Hi pozhy,

Can you elaborate a bit what do you mean when you say start hour? Do you want the indicator to start drawing on that hour?

Best Regards,

Panagiotis


@PanagiotisCharalampous

pozhy
23 Feb 2019, 16:44

RE:

Panagiotis Charalampous said:

Hi pozhy,

Can you elaborate a bit what do you mean when you say start hour? Do you want the indicator to start drawing on that hour?

Best Regards,

Panagiotis

for example, I want to draw a line every 5 hours. in the second step I want to draw that series from 5 pm 
 

            ChartObjects.DrawLine("left" + idx1, idx2, open, idx2, close, color, Thickness);


@pozhy