Login Page - Create Account

Support Board


Date/Time: Fri, 10 May 2024 17:20:22 +0000



ACSIL: GetNearestMatchForSCDateTime Always Returns -1

View Count: 952

[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.
[2018-08-17 11:27:25]
Sierra Chart Engineering - Posts: 104368
That function was not meant to be called during chart drawing and it is not supported during that time.

You need to fill out the Study Subgraph data arrays (or your own data objects) with what you require during drawing, when the standard study function is called.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2018-08-17 11:28:49

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

Login

Login Page - Create Account