Indicator does not start at midnight
Created at 01 Sep 2023, 11:53
Indicator does not start at midnight
01 Sep 2023, 11:53
I have this indicator code that should draw vertical lines every 90 min starting at 00:00, but it starts at 00:30. What do I need to add/modify that the first line each day starts at 00:00?
using System;using cAlgo.API;using cAlgo.API.Indicators;using cAlgo.API.Internals;using cAlgo.Indicators;namespace cAlgo{ [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class VerticalLinesEvery90Minutes : Indicator { [Parameter("Lookback Period (Days)", DefaultValue = 5)] public int LookbackPeriodInDays { get; set; } protected override void Initialize() { Color _color = Color.FromArgb (75, Color.Gray); DateTime currentTime = Bars.OpenTimes.LastValue; for (int i = 0; i <= LookbackPeriodInDays; i++) { DateTime currentDate = currentTime.Date.AddDays(-i); DateTime lineTime = currentDate.AddHours(0).AddMinutes(0); while (lineTime < currentDate.AddHours(24)) { int minutesSinceMidnight = (int)(lineTime - currentDate).TotalMinutes; if (minutesSinceMidnight % 90 == 0) { Chart.DrawVerticalLine("VerticalLine" + lineTime.ToString("yyyyMMddHHmm"), lineTime, _color, 1, LineStyle.Solid); } lineTime = lineTime.AddMinutes(90); // Increment by 90 minutes } } } public override void Calculate(int index) { // Calculate method not needed for this indicator } }}
PanagiotisChar
02 Sep 2023, 07:58
Hi there,
Your code does not build neither it is in a comprehensible format. If you can fix it, I can have a look
@PanagiotisChar