Change the start hour of day

24 Jan 2019, 16:02Change the start hour of day#1
pozhyposts: 23since: 03 Apr 2018

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)

 

        }

    }

}

11 Feb 2019, 03:26RE:#2
pozhyposts: 23since: 03 Apr 2018

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

11 Feb 2019, 10:41#3
Panagiotis Charalampousposts: 3188since: 13 Jan 2017

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


Head of Community Management at cTrader
23 Feb 2019, 16:44RE:#4
pozhyposts: 23since: 03 Apr 2018

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);