Support Board
Date/Time: Sat, 01 Feb 2025 06:57:21 +0000
Post From: sc.BaseDateTimeIn values do not match displayed range bars on chart
[2019-06-24 02:41:03] |
uM8137 - Posts: 183 |
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 |
timeline_BTCQ19_25tick_rangebar_graph.png / V - Attached On 2019-06-24 02:14:15 UTC - Size: 127.01 KB - 279 views timeline_output_log.txt.png / V - Attached On 2019-06-24 02:14:24 UTC - Size: 258.83 KB - 255 views timeline_chart_settings_25tick_rangebar_standard.png / V - Attached On 2019-06-24 02:20:32 UTC - Size: 239.08 KB - 264 views |