delay DateTime
delay DateTime
22 Jul 2020, 14:22
how can I make a 1 hour delay with the DateTime function?
thanks
Replies
luca.tocchi
22 Jul 2020, 14:42
RE:
PanagiotisCharalampous said:
Hi Luca,
You can use AddHours() method.
Best Regards,
Panagiotis
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
Print(DateTime.Now);
Print(DateTime.Now.AddHours(1));
if (DateTime.Now.AddHours(1))
{
Print("ok");
}
}
}
}
I want to print "ok" after 1 hour from power on
but so it gives me error
where am i wrong?
@luca.tocchi
PanagiotisCharalampous
22 Jul 2020, 14:46
Hi Luca.
AddHours() returns a DateTime object. In the if statement you need to have a boolean variable or a comparison.
Best Regards,
Panagiotis
@PanagiotisCharalampous
... Deleted by UFO ...
PanagiotisCharalampous
22 Jul 2020, 14:24
Hi Luca,
You can use AddHours() method.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous