Need help with time functions
01 Nov 2014, 08:42
Hi,
I'm trying to code a simple indicator to insert vertical lines on the chart at specific hours.
However I don't understand time functions and am struggling to find tutorials / examples to illustrate
the various functions.
Any help with my broken code would me much appreciated.
Thanks
apresau
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TimeMarkers : Indicator
{
[Parameter(DefaultValue = 12)]
public int Hour_1 { get; set; }
[Parameter(DefaultValue = 16)]
public int Hour_2 { get; set; }
private DateTime _Hour_1, _Hour_2;
protected override void Initialize()
{
}
public override void Calculate(int index)
{
_Hour_1 = new DateTime(Hour_1, 0, 0);
_Hour_2 = new DateTime(Hour_2, 0, 0);
if (Server.Time.Date.AddHours(0) == _Hour_1)
ChartObjects.DrawVerticalLine("vLine_1", index, Colors.Red, 1, LineStyle.Lines);
if (Server.Time.Date.AddHours(0) == _Hour_2)
ChartObjects.DrawVerticalLine("vLine_2", index, Colors.Gold, 1, LineStyle.Lines);
}
}
}

Invalid
03 Nov 2014, 09:17
RE:
DateTime initialization is wrong.
Currently you use this one (Year, Month, Hour). You need to create a date time using (year, month, day, hour, minutes, seconds).
apresau said:
@Invalid