Topics
06 Jun 2019, 17:34
 1230
 3
16 May 2019, 04:33
 1499
 3
08 May 2019, 00:41
 1218
 3
07 May 2019, 13:26
 1082
 1
26 Apr 2019, 04:45
 1732
 5
24 Apr 2019, 21:34
 1107
 1
Replies

lec0456
04 Oct 2013, 10:15

RE:

Spotware said:

Yes. Version with the fix is already released for our demo build. You can download it from www.spotware.com

That spotware version looks great!  When will it be rolled out to the brokers?


@lec0456

lec0456
29 Sep 2013, 01:21

Has the bug been fixed?


@lec0456

lec0456
20 Sep 2013, 08:49

Ok, that sounds good.  But how many trend bars will be displayed.  Whats the logic used to determine how far back before a date range the back testing will go?


@lec0456

lec0456
20 Sep 2013, 08:46

I think that could cause discrepancies with backtesting.  But, this is very complicated, you have to test it for situation and broker.  Things to look for are transitions from day to day and week to week.  Thats were you can observe inconsistent behavior.


@lec0456

lec0456
19 Sep 2013, 19:13

for now, If you leave everything in UTC.  Robot Time, Indicator time, User Time, and don't convert anything you should be ok.  The problem is that as Daylight savings is applied to different regions your calculation for starting a strategy at say 8am ny time or any specific session would have to be changed manually.


@lec0456

lec0456
17 Sep 2013, 19:21 ( Updated at: 21 Dec 2023, 09:20 )

I created a robot to test this and the indicator is not inheriting the timezone from the robot.  In this example, the robot is starting the day at 17:00 and the indicator is starting the new day at 21:00

Here is the code:

//#reference: C:\Users\lcespedes\Documents\cAlgo\Sources\Indicators\MarketHours.algo
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.EasternStandardTime)]
    public class TimeZoneTest : Robot
    {

        private MarketHours markethours;
        private TimeZoneInfo BrokerTimeZone;


        protected override void OnStart()
        {
            markethours = Indicators.GetIndicator<MarketHours>();
            
            var attribute = (RobotAttribute)typeof(TimeZoneTest).GetCustomAttributes(typeof(RobotAttribute), false)[0];
            BrokerTimeZone = TimeZoneInfo.FindSystemTimeZoneById(attribute.TimeZone);
            //BrokerTimeZone = TimeZoneInfo.FindSystemTimeZoneById("E. Europe Standard Time");
            Print("RobotTimeZone Setting: {0}", attribute.TimeZone);
            Print("RobotTimeZone Name: {0}", BrokerTimeZone.DisplayName);
            Print("Offset: {0}", BrokerTimeZone.BaseUtcOffset);
            Print("DST: {0}", BrokerTimeZone.SupportsDaylightSavingTime);
        }
 
 
        protected override void OnBar()
        {
            int t0 = MarketSeries.Close.Count - 1;
            //** t0 results are not final because the bar has not completed
            int t1 = t0 - 1; 
 
            if (t1 < 0)return;

            DateTime BrokerTime = DateTime.SpecifyKind(MarketSeries.OpenTime[t0],DateTimeKind.Unspecified);
            TimeZoneInfo NYTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
            DateTime NYTime = TimeZoneInfo.ConvertTime(BrokerTime, BrokerTimeZone, NYTimeZone);
            double NYValue = (NYTime.Hour * 100) + NYTime.Minute;
            
//** Day End Processes Start
            if (NYValue==1700){
            Print("BrokerTime: {0} , NYTime: {1}", BrokerTime, NYTime);
            Print("Robot New Day****" + Server.Time.ToString("MM/dd/yyyy HH:mm") + "*****");}
            
            if (markethours.NewYork[t1] == 1655)
            {
                Print(NYValue);
                Print("Indicator New Day*****" + Server.Time.ToString("MM/dd/yyyy HH:mm") + "*****");
                Print(Server.Time.Kind);
            }
//** Day End Processes Start
        }
    }
}

Please let me know whats going on...


@lec0456

lec0456
17 Sep 2013, 17:25

I'm getting different behavior depending if I test the robot in real-time or backtested.


@lec0456

lec0456
16 Sep 2013, 18:44 ( Updated at: 21 Dec 2023, 09:20 )

So Here is whats happening.  Do you see the 2 period separators? It goes from Friday sept 13th, shows activity saturday sept 14th and jumps to monday sept 16th.Notice user time is set to UTC+3.

So now I move from the backtest page to the realtime robot page.  I keep the same user timezone setting of UTC+3.  How many period separators do you see?  One, thats the way UTC+3 is supposted to behave.  It show 5 days per week not 6.  So, time in backtesting is being handled differently from real-time.  So, if any of your trading strategies are based on timing, backtesting is worthless...This needs to be fixed!


@lec0456

lec0456
16 Sep 2013, 10:27

Ok, correct me if I'm wrong.

It seems that when you backtest a robot set to E.Europe Time its chart is rendered in E.Europe Time.  So you have to change the User time(bottom right drop down) to UTC, so there is no offset.  

But that means I have to change the timezones of my indicators to UTC so they are in sync.

I don't think this is the behavior you want for backtesting.  Backtesting should simulate realtime as much as posible.  So the chart should render in UTC so you can apply your user time the same way as inn realtime.  I mean that if I like to see my realtime charts in UTC+3, I should not have to change it for backtesting.  That goes for indicators also,  I should not have to set my indiccators for one timezone with realtime trading and another for backtesting.

 

 


@lec0456

lec0456
15 Sep 2013, 22:51

protected override void OnStart()
        {
            markethours = Indicators.GetIndicator<MarketHours>();
            
            var attribute = (IndicatorAttribute)typeof(MarketHours).GetCustomAttributes(typeof(IndicatorAttribute), false)[0];
            //BrokerTimeZone = TimeZoneInfo.FindSystemTimeZoneById(attribute.TimeZone);
            BrokerTimeZone = TimeZoneInfo.FindSystemTimeZoneById("E. Europe Standard Time");
            Print("RobotTimeZone Setting: {0}", attribute.TimeZone);
            Print("RobotTimeZone Name: {0}", BrokerTimeZone.DisplayName);
            Print("Offset: {0}", BrokerTimeZone.BaseUtcOffset);
            Print("DST: {0}", BrokerTimeZone.SupportsDaylightSavingTime);

        }

I Inserted the above code and it shows that the attribute.TimeZone property is returning UTC no matter what the robot is set to!!!!!


@lec0456

lec0456
15 Sep 2013, 21:45

It seems like even if you change the range setting, the chart starts several days before randomly.


@lec0456

lec0456
15 Sep 2013, 04:12

BTW, the robot is expecting to be run on a 5min time frame.  Thats why it tests the previous bar for 16:55 before indicating a new day


@lec0456

lec0456
13 Sep 2013, 22:00

Any ETA on this issue?


@lec0456

lec0456
12 Sep 2013, 14:09

I hope you will have an answer for this soon! Its extremely important to have the time working properly within indicators and robots. and between indicators and robots.


@lec0456

lec0456
10 Sep 2013, 17:54

ok, I'm glad you will investigate.  However, for the first behavior I described.  And Time one behavior is a little hard to explain so let me go slowly.

True, a new day starts at 17:00EST or 21;00UTC or 00:00EEST.  However, the robot will print out the new day as 21:00 no matter what time zone you set the robot.  

So, in my opinion what seems to be happpening is that the indicator is reverting to using UTC time no matter what the robot says.  And that would be consistent with the behavior of the Kind property.


@lec0456

lec0456
02 Sep 2013, 07:44

Is there a way to set a TimeZoneInfo variable equal to the TimeZone setting of the robot?

 TimeZoneInfo myTimeZone =<RobotTimeZone>;


@lec0456

lec0456
02 Sep 2013, 07:42

Can you explain technically what setting the TimeZone is doing within the robot?


@lec0456

lec0456
26 Aug 2013, 16:40

OK, thanks


@lec0456

lec0456
16 Aug 2013, 20:04

 I just wanted to be sure of the behavior.  I don't have an opinion on whether inheritance is necessary or not.

 

One last question on aggregation on the daily chart.  from what time does it aggregate daily data?


@lec0456

lec0456
16 Aug 2013, 10:45

What if, for example the robot time zone is set to W. Europe and the Indicator, the robot uses, is explicitly set to a different time zone.  Will cAlgo ignore the time zone of the indicator?


@lec0456