Login Page - Create Account

Support Board


Date/Time: Mon, 21 Apr 2025 23:45:07 +0000



How to access to the SCStudyInterfaceRef object from inside a thread?

View Count: 391

[2025-02-18 16:13:50]
LTSys - Posts: 68
Is is possible to get access to the "SCStudyInterfaceRef sc" object from inside a thread?

This "SCStudyInterfaceRef sc" object is passed to the SCSFExport functions within the study... but I would like to get access to it from a thread that is running on a timed interval.

For example...

void ReadPositions() {

SCStudyInterfaceRef sc = // How to access it? I can't pass it as a parameter because I need to get the latest version from inside the running thread.

s_SCPositionData position;

sc.GetTradePosition(position);

// more logic here
}

Is this possible or is this a design limitation in Sierra Chart studies?

TIA
Date Time Of Last Edit: 2025-02-19 17:20:05
[2025-02-18 16:27:37]
Sierra_Chart Engineering - Posts: 19290
This is not safe:
but I would like to get access to it from a thread that is running on a timed interval.

On the thread that calls the study function, you need to take a copy of the data, you want from SCStudyInterfaceRef sc and place it into your own allocated memory. And then, access that allocated memory, on the separate thread. And then there must be a critical section to protect that block of memory. We recommend using an operating system critical section.

There is no safe way to do this other than explained.

Otherwise Sierra Chart will become unstable.
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, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2025-02-18 18:22:31]
LTSys - Posts: 68
Thanks for detailing the solution.

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

Login

Login Page - Create Account