Support Board
Date/Time: Wed, 30 Oct 2024 22:56:03 +0000
[Programming Help] - Storing SCDateTime-data in a subgraph array?
View Count: 731
[2020-11-24 19:50:46] |
kraut - Posts: 20 |
I am currently upgrading my old ACSIL code to Sierra Chart version 2200. In my multi-timeframe helper class, I used to keep SCDateTime values as (float) in a subgraph array (sc.Subgraph[].Arrays[][]). In Sierra Chart version 2200, is there a way to store SCDateTime data in subgraph arrays? Update: How about casting the result of SCDateTime#GetAsDouble() to (float) and then storing it in a subgraph array? Would that only lose below-second resolution? Date Time Of Last Edit: 2020-11-25 21:38:22
|
[2020-11-25 22:13:53] |
kraut - Posts: 20 |
To answer my own question: I just found out that the double floating point representation is the same as in Excel. Therefore, the resolution of a date time value down-casted to float should have a precision up to an hour (100 years * 365 days * 24 hours = 876,000, i.e. 6 digits, which should be stored near full precision in a float variable). Minutes, however would not be guaranteed to be represented correctly. The float range is 3.4E +/- 38 (7 digits). |
[2023-03-18 23:04:56] |
Tony - Posts: 511 |
I have the same issue. I found this in the SCDateTime Document: Working with the SCDateTime Variables and Values: GetAsDouble() I guess a float number should be able to handle any date value (the integer portion): (2023-1899) x 365 = 45260 days It is just the time part, DataTimeValue.GetTimeInSeconds()/864000000 that the float number doesn't have enough precision? Right now, I have no problem get the accurate date, but the time has quite a few minutes difference from Main Graph, wonder if there are any ways to get around this? Date Time Of Last Edit: 2023-03-18 23:19:31
|
[2023-03-19 03:55:11] |
Tony - Posts: 511 |
I found one of the possible solutions is to use 2 arrays of that subgraph, one for Date and one for TimeInSeconds, SCFloatArrayRef CustomDate = sc.Subgraph[0].Arrays[0]; SCFloatArrayRef CustomTimeInSeconds = sc.Subgraph[0].Arrays[1]; and to get the date and time for Index_N: SCDateTime DT = 1.0 * CustomDate[Index_N] + 1.0*CustomTimeInSeconds[Index_N] / 86400.0; It works, I am just hoping there is a simpler way of doing it. Date Time Of Last Edit: 2023-03-22 15:15:46
|
To post a message in this thread, you need to log in with your Sierra Chart account: