Login Page - Create Account

Support Board


Date/Time: Mon, 16 Jun 2025 01:03:16 +0000



GetStudyArraysFromChartUsingID Empty Array

View Count: 287

[2025-05-12 13:31:15]
Gradient - Posts: 143
Hi,

I'm using the sc.GetStudyArraysFromChartUsingID method to read in an array from another chart.

I have two charts. Chart 1 and Chart 2.

I have two studies. Study A and Study B.

Study A is applied to Chart 1.

Study B is applied to Chart 2.

Study B reads an array using the above method from Study A.

When I apply Study B to Chart 2 and use Chart 2's chart number, the associated array being read in from Study A is empty. It doesn't update as the values change.

However, when I apply Study B to Chart 1, change the chart number from Chart 2's chart number to Chart 1's chart number, Study B reads the array from Study A with no issues.

Can someone advise why this is and how to correct this?

Thanks
[2025-05-12 13:45:20]
User431178 - Posts: 712
Take a look at calculation precedence: ACSIL Interface Members - Variables and Arrays: sc.CalculationPrecedence
[2025-05-12 14:12:19]
Gradient - Posts: 143
Thanks.

I added that to both studies but still experiencing the same issue.
[2025-05-12 14:54:46]
User431178 - Posts: 712
Added what to both?
The point was not necessarily to add anything, just to consider that calculation precedence might be an issue.

What is the calculation precedence of study A?
What is the calculation precedence of study B?
Where is study B in the studies to graph window vs. study A?

In other words is B being calculated before A?

Here is some more information: Chart Studies: Study Calculation Precedence And Related Issues

If none of that is the answer, maybe post the code for further help?
Are studies A and B both custom?
Date Time Of Last Edit: 2025-05-12 14:55:07
[2025-05-12 17:04:26]
Gradient - Posts: 143
Calculation precedence wasn't explicitly set in the defaults of Study B.

I added sc.CalculationPrecedence = STD_PREC_LEVEL to Study B.

Study A original had this value set to LOW_PREC_LEVEL.

This was changed to sc.CalculationPrecedence = STD_PREC_LEVEL in Study A.

Study B is the only study on Chart 2.

Study A is the second study on Chart 1.

A & B are both custom studies
[2025-05-12 17:26:43]
User431178 - Posts: 712

Study B is the only study on Chart 2.
Study A is the second study on Chart 1.
A & B are both custom studies

If the studies are on different charts, calculation precedence is not the problem.


When I apply Study B to Chart 2 and use Chart 2's chart number, the associated array being read in from Study A is empty. It doesn't update as the values change.

I guess I misread this before.
Why would you use chart 2's chart number if you want to read data from a study on chart 1, of course it will not work.
The function requires the source chart number, the one you want to read from, not the chart you are calling the function from.


However, when I apply Study B to Chart 1, change the chart number from Chart 2's chart number to Chart 1's chart number, Study B reads the array from Study A with no issues.

Yes, because now the function has the correct argument passed in, the source chart number.

Sorry for the confusion with precedence, I will try to read more carefully in future.
[2025-05-12 22:46:56]
Gradient - Posts: 143
The function should read the data from which ever chart the study is active on.

For example if there is a custom study on Chart 1 and I want to read it on Chart 2, then I should pass in Chart 1's chart number into the sc.GetStudyArraysFromChartUsingID on Chart 2.

This is what is being done but there is no data being received on Chart 2 from Chart 1.

To test that the issue wasn't with the custom study, I placed the same custom study being used on Chart 2 on Chart 1 and then passed Chart 1's chart number into the study and it read the data fine.

This proved that the issue wasn't the logic of study as all that was changed was the chart number being referenced.

The custom study that uses sc.GetStudyArraysFromChartUsingID should work regardless of which chart number is being used. It's not limited to only being used on the Chart that contains the reference study. (i.e. Chart 1)

If using with the source chart, you would just use sc.ChartNumber and there would be no need to have an sc.Input variable for setting the chart number.

I created an sc.Input variable for the chart number because I don't want to read the study on the Source chart. I would like to read it on a different chart.
Date Time Of Last Edit: 2025-05-12 22:49:15
[2025-05-13 09:37:36]
User431178 - Posts: 712

For example if there is a custom study on Chart 1 and I want to read it on Chart 2, then I should pass in Chart 1's chart number into the sc.GetStudyArraysFromChartUsingID on Chart 2.

Yes, that is correct, but that is not what you wrote before.

When I apply Study B to Chart 2 and use Chart 2's chart number, the associated array being read in from Study A is empty. It doesn't update as the values change.


The custom study that uses sc.GetStudyArraysFromChartUsingID should work regardless of which chart number is being used. It's not limited to only being used on the Chart that contains the reference study. (i.e. Chart 1)

Yes, and that is exactly how it does work.
If it not doing that for you, then something is wrong with what you are doing.

Super basic working example attached.
imagedatafromchart.png / V - Attached On 2025-05-13 09:36:48 UTC - Size: 84.68 KB - 85 views
attachmentReadFromOtherChart.cpp - Attached On 2025-05-13 09:37:07 UTC - Size: 2.16 KB - 102 views

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

Login

Login Page - Create Account