Serious bug in Realtime mode

ME-Pepper's avatar

ME-Pepper since: 22 Sep 2022;

  22 Sep 2022, 10:06
Serious bug in Realtime mode

Hi 

I think there is a serious bug in cTrader Automate in Relatime mode:
Occasionally the DateTime value of Time is far in the future.

Because of this, Time cannot be used to find edges of i..e. a new hour, day or minute comparing it to the time one tick before.

This cBot reproduces the bug:
 

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, TimeZone = TimeZones.WEuropeStandardTime)]
    public class cTimeBug : Robot
    {
        DateTime prevTime;

        protected override void OnStart()
        {
            prevTime = Time;
            var timeCurrent = Time;
            var timeServer = Server.Time;
            var timeNow = DateTime.Now;
            var time2nd = Time;
            Print("=========== OnStart =============");
            Print("Time: " + timeCurrent + ", PrevTime: " + prevTime);
            Print("Server time: " + timeServer + ", 2ndTime: " + time2nd + ", Time Now: " + timeNow);
            Print("=========== Going to OnTick =====");
        }

        protected override void OnTick()
        {
            var timeCurrent = Time;
            var timeServer = Server.Time;
            var timeNow = DateTime.Now;

            if (timeCurrent - prevTime > TimeSpan.FromDays(1))
            {
                var time2nd = Time;
                Print("======= cTrader Bug ============");
                Print("Time: " + timeCurrent + ", PrevTime: " + prevTime);
                Print("Server time: " + timeServer + ", 2ndTime: " + time2nd + ", Time Now: " + timeNow);
                Print("======= Stoppping ==============");
                Stop();
                return;
            }

            prevTime = timeCurrent;
        }

        protected override void OnStop()
        {
            // Handle cBot stop here
        }
    }
}

This will be printed out:

lease note that the print out time of the last two lines is also wrong and is put at the end. Correctly the last two lines should be printed out right after the =========== Going to OnTick ===== line.

20/09/2022 08:35:33.452 | CBot instance [cTimeBug, EURUSD, h1] started.

20/09/2022 08:35:34.795 | =========== OnStart =============

20/09/2022 08:35:34.795 | Time: 20.09.2022 08:35:34, PrevTime: 20.09.2022 08:35:34

20/09/2022 08:35:34.795 | Server time: 20.09.2022 08:35:34, 2ndTime: 20.09.2022 08:35:34, Time Now: 20.09.2022 08:35:34

20/09/2022 08:35:34.795 | =========== Going to OnTick =====

20/09/2022 08:40:08.367 | Server time: 09.11.2022 00:42:55, 2ndTime: 09.11.2022 00:42:55, Time Now: 20.09.2022 08:40:08

20/09/2022 08:40:08.367 | ======= Stoppping ==============

20/09/2022 08:40:08.476 | CBot instance [cTimeBug, EURUSD, h1] stopped.

09/11/2022 01:42:55.646 | ======= cTrader Bug ============

09/11/2022 01:42:55.646 | Time: 09.11.2022 00:42:55, PrevTime: 20.09.2022 08:40:08


Best 
Heinrich
 

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  22 Sep 2022, 10:37

Hi ME-Pepper,

Which version of cTrader do you use?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Head of Community Management at cTrader
ME-Pepper's avatar

ME-Pepper since: 22 Sep 2022;

  22 Sep 2022, 10:49
RE:

PanagiotisCharalampous said:

Hi ME-Pepper,

Which version of cTrader do you use?

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Version 4.2.22

PS: I think it is easier to reproduce the bug when memory on the computer gets limited. I.e. On a 4GByte computer starting Visual studio while the bot is running.

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  22 Sep 2022, 10:54

Hi ME-Pepper,

Can you try reproducting this on 4.3.12? It's a cross broker version and this issue should have been fixed there.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Head of Community Management at cTrader
ME-Pepper's avatar

ME-Pepper since: 22 Sep 2022;

  22 Sep 2022, 11:02
RE:

PanagiotisCharalampous said:

Hi ME-Pepper,

Can you try reproducting this on 4.3.12? It's a cross broker version and this issue should have been fixed there.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


How do I get the newer Version 4.3.12 on a Pepperstone account?

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  22 Sep 2022, 11:45

Hi ME-Pepper,

If you download and install the link I provided, you will be able to access your Pepperstone account.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Head of Community Management at cTrader
ME-Pepper's avatar

ME-Pepper since: 22 Sep 2022;

  24 Sep 2022, 09:25
RE:

PanagiotisCharalampous said:

Hi ME-Pepper,

If you download and install the link I provided, you will be able to access your Pepperstone account.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Ok, seems to work now.

Thx