Login Page - Create Account

Support Board


Date/Time: Tue, 30 Apr 2024 21:01:46 +0000



sc.BaseDateTimeIn values do not match displayed range bars on chart

View Count: 642

[2019-06-24 02:41:03]
uM8137 - Posts: 180
SierraChart version: 1915
symbol: F.US.BTCQ19 [CBV]
data source: CQG FIX.
Bar Period Type: Range Per Bar - Standard (in Ticks), 25 ticks.

When I compare the timestamps reported in sc.BaseDateTimeIn (and sc.BaseDataEndDateTime) to
the timestamps on the chart at the bottom horizontal axis, they appear nothing alike.
Please see the detailed example in the two tables below, and the reproducer code included.

Prima facia, this seems like a rather serious problem in writing ACSIL trading systems.

But perhaps the SCDateTimeToUNIXTime() function is buggy?

Specifically, in the example here, the chart shows these timestamps (in Chicago time zone):


displayed on chart bar begin times
-------------------
2019-06-19 17:00:44
2019-06-19 22:42:56

2019-06-20 02:58:11
2019-06-20 08:41:52
2019-06-20 10:55:48
2019-06-20 12:05:33
2019-06-20 13:36:19
2019-06-20 14:59:12
2019-06-20 17:00:24
2019-06-20 20:01:05
2019-06-20 20:43:55
2019-06-20 21:37:02

from running the print_timeline DLL study (see also 2nd screenshot):


times reported to the ACSIL DLL in sc.BaseDateTimeIn:
----------------------------------------------
2019-06-19 12:00:44 Central Daylight Time
2019-06-19 17:42:56 Central Daylight Time
2019-06-19 21:58:11 Central Daylight Time

2019-06-20 03:41:52 Central Daylight Time
2019-06-20 05:55:48 Central Daylight Time
2019-06-20 07:05:33 Central Daylight Time
2019-06-20 08:36:19 Central Daylight Time
2019-06-20 09:59:12 Central Daylight Time
2019-06-20 12:00:24 Central Daylight Time
2019-06-20 15:01:05 Central Daylight Time
2019-06-20 15:43:55 Central Daylight Time
2019-06-20 16:37:02 Central Daylight Time

complete code for the ASCIL dll:


#include "sierrachart.h"

SCDLLName("print_timeline")

#define vv(args...) \
do {SCString Msg; Msg.Format(args); sc.AddMessageToLog(Msg, 0);} while(0);


char* timeToString(int64_t unixtm, char buf[60], bool chopNanos) {
time_t tt;
struct tm ts;

if (chopNanos) {
tt = (time_t)(unixtm/1000000000);
} else {
tt = (time_t)unixtm;
}

// Format time, "ddd yyyy-mm-dd hh:mm:ss zzz"
ts = *localtime(&tt);
strftime(buf, 60, "%a %Y-%m-%d %H:%M:%S %Z", &ts);
buf[59] = '\0';
return &buf[0];
}

char* timeNowString(char buf[60]) {
time_t timev;
time(&timev);
memset(&buf[0],0,60);
return timeToString(int64_t(timev), buf, false);
}

SCSFExport scsf_PrintTimeline(SCStudyInterfaceRef sc)
{
int& access = sc.GetPersistentInt(0);
access++;

// Set configuration variables
if (sc.SetDefaults)
{
sc.AutoLoop = 0;

// During development only set to 1
sc.FreeDLL = 1;

// want end times of bars too.
sc.MaintainAdditionalChartDataArrays = 1;

// Must return
return;
}

if (access < 10) {
vv("======== access = %i =========================", access)
for (int i = 0; i < sc.ArraySize; i++) {

int64_t tmBeg = SCDateTimeToUNIXTime(sc.BaseDateTimeIn[i]); // seconds since epoch.
char tmBufBeg[60];
timeToString(tmBeg, tmBufBeg, false);
vv("tmBeg[%005d] = '%s'", i, (const char*) &tmBufBeg[0]);

int64_t tmEnd = SCDateTimeToUNIXTime(sc.BaseDataEndDateTime[i]); // seconds since epoch.
char tmBufEnd[60];
timeToString(tmEnd, tmBufEnd, false);
vv("tmEnd[%005d] = '%s'", i, (const char*) &tmBufEnd[0]);
}
}
}

log output from running code:

Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | ======== access = 9 ========================= | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00000] = 'Wed 2019-06-19 12:00:44 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00000] = 'Wed 2019-06-19 17:42:56 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00001] = 'Wed 2019-06-19 17:42:56 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00001] = 'Wed 2019-06-19 21:58:11 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00002] = 'Wed 2019-06-19 21:58:11 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00002] = 'Thu 2019-06-20 03:41:52 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00003] = 'Thu 2019-06-20 03:41:52 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00003] = 'Thu 2019-06-20 05:55:47 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00004] = 'Thu 2019-06-20 05:55:48 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00004] = 'Thu 2019-06-20 07:05:19 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00005] = 'Thu 2019-06-20 07:05:33 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00005] = 'Thu 2019-06-20 08:36:12 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00006] = 'Thu 2019-06-20 08:36:19 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00006] = 'Thu 2019-06-20 09:59:12 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00007] = 'Thu 2019-06-20 09:59:12 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00007] = 'Thu 2019-06-20 10:58:15 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00008] = 'Thu 2019-06-20 12:00:24 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00008] = 'Thu 2019-06-20 15:01:05 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00009] = 'Thu 2019-06-20 15:01:05 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00009] = 'Thu 2019-06-20 15:43:55 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00010] = 'Thu 2019-06-20 15:43:55 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00010] = 'Thu 2019-06-20 16:37:00 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmBeg[00011] = 'Thu 2019-06-20 16:37:02 Central Daylight Time' | 2019-06-23 21:03:16
Chart: F.US.BTCQ19 [CBV] 125 Range #1 | Study: Custom DLL Study | tmEnd[00011] = 'Thu 2019-06-20 18:59:40 Central Daylight Time' | 2019-06-23 21:03:16

imagetimeline_BTCQ19_25tick_rangebar_graph.png / V - Attached On 2019-06-24 02:14:15 UTC - Size: 127.01 KB - 252 views
imagetimeline_output_log.txt.png / V - Attached On 2019-06-24 02:14:24 UTC - Size: 258.83 KB - 232 views
imagetimeline_chart_settings_25tick_rangebar_standard.png / V - Attached On 2019-06-24 02:20:32 UTC - Size: 239.08 KB - 225 views
[2019-06-24 02:51:50]
uM8137 - Posts: 180
I see the time stamps all differ by exactly 5 hours, which is the Chicago (CDT) vs UTC time difference.
[2019-06-24 02:55:24]
uM8137 - Posts: 180
So I guess the bug is simply that the chart shows UTC times even when both

a) DTS -> TimeZone is set to Chicago

and

b) CS -> Advanced Settings -> Time Zone is set to Chicago
[2019-06-24 03:04:28]
Sierra Chart Engineering - Posts: 104368
Nothing you are saying here can be technically correct. Post #3 is completely untrue.

sc.BaseDateTimeIn (and sc.BaseDataEndDateTime) are in the same time zone as the chart.

It is not within the scope of our support to analyze this further. There could not be whatsoever And we mean 100% not whatsoever any problem like you are saying. It is just technically impossible.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-06-24 03:08:27]
Sierra Chart Engineering - Posts: 104368
One reason why what you are saying is completely untrue in this thread is because this array: sc.BaseDateTimeIn is the very same array which contains the Date-Times displayed on the timescale at the bottom of the chart without any conversion.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2019-06-24 03:09:29
[2019-06-24 04:56:09]
uM8137 - Posts: 180
The explanation is completely rational, as it always is for computers.

For some reason UI updates were not getting applied. I found could change the time zone settings and the graph would not get re-drawn with the new times. I updated to the latest and it doesn't seem to happen with v1939.
[2019-06-24 16:22:35]
Sierra Chart Engineering - Posts: 104368
That could not be the case either. There have been no changes with reloading the chart after there is a time zone change, and that works consistently reliably. And in any case, one of the time zones would always apply to the chart whether the chart specific one or the global one.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2019-06-24 16:22:47

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account