ChartObjects: draw vertical lines at equidistant intervals

Created at 15 Sep 2015, 09:43
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!
MaVe's avatar

MaVe

Joined 24.08.2015

ChartObjects: draw vertical lines at equidistant intervals
15 Sep 2015, 09:43


I want to draw vertical lines at equidistant intervals.
The first vertikal line is defined by date and time.
The interval is also a give time, format:  Days Hours Minutes Seconds.

Does someone know how to define the interval?
The code so far:

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

namespace cAlgo
{
    [Indicator(IsOverlay = true, AutoRescale = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MaVe2015 : Indicator
    {
        protected override void Initialize()
        {
            // Initialize and create nested indicators
        }

        public override void Calculate(int index)
        {
            var Day1 = new DateTime(2015, 9, 15, 7, 15, 0);
            ChartObjects.DrawVerticalLine("D1", Day1, Colors.Blue, 1, LineStyle.Solid);
        }
    }
}

 


@MaVe
Replies

Spotware
15 Sep 2015, 10:05

Dear Trader,

You could identify the index of a bar based on the exact time using the GetIndexByExactTime method and then for a certain number of bars (interval) you could draw a vertical line using the DrawVerticalLine based on the index.

We would like to inform you that we do not provide coding assistance services. We more than glad to assist you with specific questions about cAlgo.API. You can also contact one of our Partners or post a job in Development Jobs section for further coding assistance.


@Spotware