Support Board
Date/Time: Sat, 15 Mar 2025 03:47:23 +0000
[Programming Help] - sc.BaseDateTimeIn[BarIndex].GetAsDouble() return time only without correct date
View Count: 730
[2022-07-15 00:40:17] |
User189399 - Posts: 46 |
I use "const double StartT = sc.BaseDateTimeIn[BarIndex].GetAsDouble()" to get the timestamp of a bar in my Renko chart. It return 44744.166956 which equal to 1970-01-01 20:25:44.168600. The date is incorrect. Please advise how to fix it.
|
[2022-07-15 09:03:10] |
User907968 - Posts: 838 |
It return 44744.166956 which equal to 1970-01-01 20:25:44.168600. The date is incorrect.
Are you sure about that? How do you arrive at that conclusion? This is what I make it - 2022-07-02 04:00:25 Working with the SCDateTime Variables and Values: Date Values Working with the SCDateTime Variables and Values: Time Values |
[2022-07-15 15:23:31] |
User189399 - Posts: 46 |
I suppose to export the timestamp of the bars and then input to my Python with the code datetime.fromtimestamp() I have verified the timestamp result returned by sc.BaseDateTimeIn[BarIndex].GetAsDouble() with the Timestamp converter below https://timestamp.online The timestamp of 2022-07-02 04:00:25 is 1656705625 not the 44744. It seems the return value from GetAsDouble() is not the standard timestamp. Pls advise the formula how the SCDateTime to calculate its numerical time value or suggest any function that can convert the datetime value to the standard timestamp. |
[2022-07-15 15:54:04] |
User907968 - Posts: 838 |
That function does not return a unix timestamp, so no use to try and verify with it with a unix timestamp converter. Look in the scdatetime.h file and you can see that there are other conversion functions. Here is a link to a solution posted by another user for converting SCID files using python. Maybe you can see how the datetime variable is handled and apply similar logic in your solution? Python for Sierra Chart |
[2022-07-15 15:57:19] |
John - SC Support - Posts: 38678 |
Refer to the information at the following link that gives more information on how Sierra Chart stores Date/Time: Spreadsheet Functions: Serial DateTime Values For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: