server time in the future
server time in the future
18 Oct 2022, 12:00
Hello
When calling the Time property which supposed to return current server time, I get a time in the future (usually somewhere in December 22) which of course cannot be.
I've added a simple bot to illustrate that problem. You can run it on several symbols (for me it happened on EURUSD h1 and BTCUSD h1) and usually within several minutes/hours you will get this error.
Thank you
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class TimeDiffTester : Robot
{
[Parameter(DefaultValue = "Hello world!")]
public string Message { get; set; }
protected override void OnStart()
{
// To learn more about cTrader Automate visit our Help Center:
// https://help.ctrader.com/ctrader-automate
Print(Message);
}
protected override void OnTick()
{
DateTime serverTime = Time;
DateTime localTime = DateTime.Now;
double timeDiff = serverTime.Subtract(localTime).TotalDays;
if (timeDiff > 1)
{
Print("timeDiff > 1");
Print("serverTime= " + serverTime);
Print("localTime=" + localTime);
Print("timeDiff= " + timeDiff);
Stop();
}
}
protected override void OnStop()
{
// Handle cBot stop here
}
}
}
Replies
eynt
20 Oct 2022, 12:17
RE:
Hello
one is 4.2.22.8460 and the other is 4.2.22.8451.
Please try to run the sample bot on as much symbols as possible so it will make the process of reproducing the bug as fast as possible. You can try to run the cBot for a few days to be sure although for me it took no more than a few hours.
My cTrader is configured as UTC+3 perhaps it's related.
Thanks
@eynt
eynt
19 Oct 2022, 10:13
RE:
Hello
Where you able to reproduce the bug?
@eynt