OnBar/Time Issue

Created at 07 Sep 2022, 13:02
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
XA

Xammo

Joined 23.06.2021

OnBar/Time Issue
07 Sep 2022, 13:02


I have a simple bot that I want to execute a trade every bar/hour

I was using OnBar to achieve this but when running it in demo I noticed it had opened trades occasionally at random minutes into an hour

I decided to try using server.time.hour in OnTick thinking there was something wrong with OnBar and couldn't be bothered to try and work out what

It seemed to be running ok but now that I've started testing LIVE with the code it's opening trades a few times an hour at random minutes and even timestamped one of the entries as being in October! (It's September now)

So I created the following simple code to see what is going on

using cAlgo.API;

namespace cAlgo.Robots
{
    [Robot(AccessRights = AccessRights.FullAccess)]
    public class Margin : Robot
    {
        private int int_server_TimeInUTC_Previous;

        protected override void OnStart()
        {
            int_server_TimeInUTC_Previous = Server.TimeInUtc.Hour;

            Print("STARTED");
        }
        protected override void OnBar()
        {
            Print("OnBar");
        }
        protected override void OnTick()
        {
            if (Server.TimeInUtc.Hour != int_server_TimeInUTC_Previous)
            {
                int_server_TimeInUTC_Previous = Server.TimeInUtc.Hour;

                Print("OnTick");
            }
        }
    }
}

 

The results so far...->

 

07/09/2022 09:13:47.912 | CBot instance [BarTest, AUDUSD, h1] started.
07/09/2022 09:13:48.553 | STARTED
07/09/2022 09:36:38.659 | OnTick
27/10/2022 02:39:25.610 | OnTick
 

Where is the 27/10/2022 coming from?!? Is this down to the broker?

I will keep it running as am pretty sure there are going to be issues with the OnBar printing too at random times but wanted to get this posted

Thanks

Max


@Xammo
Replies

Xammo
07 Sep 2022, 14:08

07/09/2022 09:13:47.912 | CBot instance [BarTest, AUDUSD, h1] started.
07/09/2022 09:13:48.553 | STARTED
07/09/2022 09:36:38.659 | OnTick
07/09/2022 10:00:00.278 | OnTick
07/09/2022 10:00:00.278 | OnBar
07/09/2022 10:50:46.540 | OnTick
07/09/2022 11:00:00.774 | OnTick
07/09/2022 11:00:00.774 | OnBar
27/10/2022 02:39:25.610 | OnTick
27/10/2022 03:53:33.350 | OnTick
 

hmmm...

I've edited the code in the LIVE bot to use OnBar (it has opened live trades on these dodgy time stamps) but highly suspect the same issue is going to occur - at least it did in demo but I just want it to work in LIVE!


@Xammo

PanagiotisCharalampous
07 Sep 2022, 14:23

Hi Xammo,

It's a known issue and will be fixed soon.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

Xammo
07 Sep 2022, 16:11

Hi Panagiotis

Thanks for your reply and honesty but this is a massive shock to hear

How long has it been known about and when is soon?

How could such a serious issue have made it through to production?

What if my bots were weeks/months into working and this happened (I presume it must be from an update?) It would completely destroy the strategy and risk serious real world $$$ losses!

I think I have seen others ask - is it possible to stop automatic cTrader updates?

I have also seen many mentions about rolling back to 4.1 but honestly I thought the platform was broker specific so how can I roll back to a generic 4.1 is that possible?

Is this issue only with 4.2/can I roll back to 4.1 and the timing will work properly please?

Thanks

Max


@Xammo

PanagiotisCharalampous
07 Sep 2022, 16:21 ( Updated at: 21 Dec 2023, 09:22 )

Hi Xammo,

You can roll back by pressing Ctrl+Alt+Shift+T. You can also use 4.3.11 which is cross broker and has this issue solved.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

Xammo
07 Sep 2022, 17:48

OK thanks I've gone for 4.3 guess I'm well out of touch/been off cTrader for the summer seems things have moved on quite a bit and cross broker seems good/presume it must be beta as 4.2 was long talked about etc. anyway I've kicked off the live bot and the BarTest bot so will keep an eye and hopefully no issues like this again thanks again for your help


@Xammo

Xammo
07 Sep 2022, 21:06

Hi Panagiotis

It does not seem this issue is solved in 4.3 at least not for me/in my particular setup

I just logged on to check how things were progressing and the BarTest bot was showing an OnTick at 13 minutes past an hour (and also the 2 EMA's I have on the chart as being loaded/unloaded at the same 13 minutes past the hour - I have only just started seeing this since upgrading to 4.2 - no idea why it is loading then unloading them or what is going on but do not think this has anything to do with my issues but would seem like the whole bot is being reloaded or something?)

Then before I copied all the info to paste in here I stupidly clicked onto the live bot as I could see no trade had been entered on the last new bar (2 had entered succesfully on the hour bars since start/I am using the OnBar to trigger the trade not the server.time in OnTick thinking if it is working in 4.3 this is the proper/better way to do things) and unfortunately I am still getting the total loss of the Automate Display in 4.3 so I lost access to everything viewable and had to resart cTrader to get things working again

I will roll back to 4.1 but these issues are really making me think twice about what is going on with cTrader I know there were many suggestions/wants from the community in the pipeline for a very very long time but core functionality issues like this I have never experienced...

Whilst I am typing this it has just turned the hour and the live bot entered the trade correctly and the BarTest bot showing both OnBar and OnTick as it should

Just thinking out loud here but could the loss of display be linked to this somehow? It seems to be happening after a certain amount of time (I hope you have seen the other trader having the same issue?) could this be when the bot tries to reload and everything gets messed up/restarted somehow even though it is already running?

Will report back with how things go in 4.1


@Xammo

Xammo
08 Sep 2022, 12:27

4.1 working rock solid all OnBar and OnTick printing as they should on the hour in the BarTest bot and no loss of automate display after kicking off half a dozen backtests and clicking between them/code editor everything working just like it always used to

It is beyond me how Spotware could allow their recent version to go into production knowing OnBar and Server.Time.Hour do not work correctly (what else isn't working?) but at least 4.1 works properly so obviously I won't be upgrading any time soon

Panagiotis before I start full swing into running bots live that will not be able to be stopped easily can you please confirm that there are no plans to force clients to update and that 4.1 is sticking around for the forseable future please?

Thanks

Max


@Xammo

PanagiotisCharalampous
08 Sep 2022, 12:29

Hi Max,

We plan to allow the use of one major version before. When we releases 4.3 to brokers, 4.1 will be forced to 4.2.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

Xammo
08 Sep 2022, 12:59

Right ok thanks for confirming but obviously you couldn't possibly release 4.3 when OnBar and Server.Time don't work in 4.2... right? (not to mention the automate display problem)

I mean am I missing something here this isn't a 'little' problem


@Xammo

PanagiotisCharalampous
08 Sep 2022, 16:47

Hi Max,

The problem was reported after the updates were released. Obviously we did not know about it.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

Xammo
08 Sep 2022, 18:06

Sure understood these things happen and am glad you know about it and are working on it and best of luck getting it sorted etc. all good - what I meant is I would assume/hope you wouldn't release 4.3/force those on 4.1 to update to 4.2 until you are 99.9999% certain all the bugs are ironed out in 4.2


@Xammo