Login Page - Create Account

Support Board


Date/Time: Mon, 20 May 2024 18:57:25 +0000



Post From: ACSIL: GetNearestMatchForSCDateTime Always Returns -1

[2018-08-17 10:56:03]
BlakJak - Posts: 108
I am calling the GetNearestMatchForSCDateTime() function on my current chart with the following code:

int a = sc.GetNearestMatchForSCDateTime(sc.ChartNumber, sc.ConvertDateTimeToChartTimeZone(endTimeStamp_, TIMEZONE_UTC));


This is being called from within my p_GDIFunction as I need to draw my custom graphics at specific places on my chart based on the timestamp that has been recorded with the graphics object. Ultimately this info is used to call the sc.BarIndexToXPixelCoordinate() function to get the x-coordinate.

I set up a breakpoint to catch if the variable 'a' was ever not equal to -1 and let the code run but the variable never changed from -1.

Quoting the documentation for GetNearestMatchForSCDateTime():

Error Return Value

This function will return -1 if the chart it is referencing does not exist or its data is not fully loaded.

When the chart it is referencing is opened and fully loaded, then the study instance that made this call will be called again and will be fully recalculated. What actually happens in this case, is that the chart the reference was made from, will have all of its studies recalculated.

I can only think the system believes the chart is not fully loaded since the chart definitely exists.

Please advise if I am using this/these function(s) incorrectly.