Login Page - Create Account

Support Board

Date/Time: Fri, 01 Dec 2023 11:00:49 +0000

[Programming Help] - ASCIL Creating TimeDeltas

View Count: 179

[2023-08-19 13:25:11]
Gradient - Posts: 22

I'm attempting to create a timedelta using ASCIL.

I've tried:

SCDateTime ExecutionTime=TradeOrder.EntryDateTime;



But these yield incorrect datetime objects (i.e. year is 1900). See Attached.

The attachment shows incorrect computations for timedelta using the the datetime objects(img TimeDelta Error2) as well as the GetMinute() called on the datetimes (img TimeDelta Error 1).

Please Advise.

imageTimeDelta Error 1.png / V - Attached On 2023-08-19 13:20:36 UTC - Size: 26.29 KB - 38 views
Attachment Deleted.
imageTimeDelta Error 2.png / V - Attached On 2023-08-19 13:23:41 UTC - Size: 21.04 KB - 36 views
[2023-08-19 14:29:00]
User431178 - Posts: 339
1) sc.BaseDateTimeIn.TimeAt(sc.Index)-ExecutionTime.GetTimeAsSCDateTime()
sc.BaseDateTimeIn.TimeAt returns the time in seconds since midnight, so subtracting an SCDateTime variable from that won't work.

2) sc.BaseDateTimeIn[sc.Index].GetMinute()-ExecutionTime.GetMinute()
Both of these return the minute part of the time, so only make sense if both times are in the same hour of the same day.
Even then the result would be the integer difference (minutes) between the two variables, so not a datetime variable.

There is information about the different functions and concepts here: Working with the SCDateTime Variables and Values

I don't think it is documented, but did you try using the SCDateTimeSpan object?
You can find SCDateTimeSpan in SCDateTime.h if you want to see how to use.

Otherwise, please post the actual code showing what you are trying to do.
Date Time Of Last Edit: 2023-08-19 14:29:11
[2023-08-19 14:56:16]
Gradient - Posts: 22

I'm attempting to compute the time since an order was sent for resting orders.
For example:

bool IsOrderFilled = TradeOrder.OrderStatusCode == SCT_OSC_FILLED;

SCDateTime ExecutionTime=TradeOrder.EntryDateTime;

//note: taking difference between execution time and basedatetime because BaseDateTime is open of
//bar and ExecutionTime is at close of bar, thus yielding a positive delta

if(((ExecutionTime.GetMinute()-sc.BaseDateTimeIn[sc.Index].GetMinute()) > 2) && !IsOrderFilled )

1) This makes sense.

2) These are both within the same hour of the same day, which is why I was thinking it should return some int value that could then be checked against come constant int. The issue is that even when I take the difference between the two expecting only an int value I'm getting back the date portion as well.

I hadn't seen SCDateTimeSpan prior but looking into it now.
[2023-08-19 15:30:30]
Gradient - Posts: 22
I found the bug.

the SCDateTime.GetMinute() method is working properly.

See Attached.

imageSCDateTime.GetMinute() Working.png / V - Attached On 2023-08-19 15:30:11 UTC - Size: 32.87 KB - 35 views
Attachment Deleted.
[2023-08-19 16:45:04]
Gradient - Posts: 22
Actually, it appears that .GetMinute() is returning the correct minute integer when called on sc.BaseDateTimeIn[sc.Index]

But is not returning the correct minute int when called on trade order.

For example,

int CurrentMinute=sc.BaseDateTimeIn[sc.Index].GetMinute()
SCDateTime ExecutionTime;
int ExecutionMinute;

s_SCTradeOrder TradeOrder;

if(TradeOrder.InternalOrderID == SellOrderId){




Returns the Current Minute as an int but returns ExecutionMinute at some different resolution despite both being SCDateTime objects.

See Attached.

Please Advise.
imageExecutionTimeMinute Error.png / V - Attached On 2023-08-19 16:45:01 UTC - Size: 13.87 KB - 36 views

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


Login Page - Create Account