Login Page - Create Account

Support Board


Date/Time: Wed, 12 Mar 2025 21:35:46 +0000



[Programming Help] - How to access sc.BaseData data from an additional symbol in ASCIL?

View Count: 1008

[2022-05-30 08:43:38]
BenjFlame - Posts: 335
Hi,
what is the proper way to access all BaseData elements for a data symbol added with "Add additional symbol" study?

I need to access all what is in sc.BaseData[][] ( ACSIL Interface Members - Variables and Arrays: sc.BaseDataIn[][] / sc.BaseData[][] ).

For example,
for an NQ chart, I added with study "Add additional symbol" an ES chart. So on same chart I have both NQ and ES.
Now from ASCIL I want to access: sc.BaseData[SC_NUM_TRADES] or sc.NumberOfTrades[] but from the added symbol ES, not base NQ.

How to do this?

I tried:

1) Import ES in an array:


SCFloatArray StudyReference3;
if (sc.GetStudyArrayUsingID(23, 0, StudyReference3) > 0 && StudyReference3.GetArraySize() > 0)
{
//Copy the study data that we retrieved using GetStudyArrayUsingID, into a subgraph data output array
SubGraph_Ref_ES[sc.Index] = StudyReference3[sc.Index];

}

So now I have ES on SubGraph_Ref_ES[sc.Index].
Now how to access from it and store it in another array?

By the way, is the step of storing the ES in an array necessary?
Date Time Of Last Edit: 2022-05-30 08:44:36
[2022-05-30 09:15:53]
User431178 - Posts: 613
Get all the arrays using this -
ACSIL Interface Members - Functions: sc.GetStudyArraysFromChartUsingID()

Or get the specific array of interest using this -
ACSIL Interface Members - Functions: sc.GetStudyArrayUsingID()


Using your example, for number of trades data:

SCFloatArray StudyReference3;
if (sc.GetStudyArrayUsingID(23, SC_NUM_TRADES, StudyReference3) > 0 && StudyReference3.GetArraySize() > 0)
{
// do stuff....
}

By the way, is the step of storing the ES in an array necessary?
No, not unless you want to.
[2022-05-30 16:17:39]
BenjFlame - Posts: 335
Thank you for your answer.
I was able indeed to access the info I needed within my example.

However, I was not able to get it with sc.GetStudyArraysFromChartUsingID().
It asks to specify a study ID, but since I want all the arrays, what am I supposed to indicate?

There are some sub studies that come with the imported symbol, which I can see from the interface, but it does not contain the ones I want.

So how can I get from a single operation, let's say:

sc.BaseData[SC_BIDNT] or sc.NumberOfBidTrades
c.BaseData[SC_NUM_TRADES] or sc.NumberOfTrades[]
sc.BaseData[SC_BIDVOL] or sc.BidVolume[]

?
[2022-05-30 16:31:28]
User431178 - Posts: 613
The study ID should reference the Add Additional Symbol study ID.
The result will be a SCGraphData object containing all the arrays from the referenced study.
You can the reference the individual arrays as required.


// Define a graph data object to get all of the study data
SCGraphData StudyData;

// Get the study data from the specified chart
sc.GetStudyArraysFromChartUsingID(ChartStudyInput.GetChartNumber(), ChartStudyInput.GetStudyID(), StudyData);

//Check if the study has been found. If it has, GetArraySize() will return the number of Subgraphs in the study.
if(StudyData.GetArraySize() == 0)
return;

// Define a reference to the first subgraph array
SCFloatArrayRef NumTrades = StudyData[SC_NUM_TRADES];

// Check if array is not empty.
if(NumTrades.GetArraySize() != 0)
{
// Get last value in array
float LastValue = NumTrades[NumTrades .GetArraySize() - 1];
}

Copied the above example from ACSIL Interface Members - Functions: sc.GetStudyArraysFromChartUsingID() and modified slightly.

You may run into problems with SC_BIDNT (and others), that needs additional arrays loaded, and it looks like Add Additonal Symbol has the first 11 arrays only.
[2022-05-30 16:40:02]
BenjFlame - Posts: 335
Thanks.... indeed the problem was that I didn't get that it was the chart number that I needed specified.
It works, but as you pointed, it misses some arrays, even if sc.MaintainAdditionalChartDataArrays = 1;

Too bad. So I guess I need to setup a physical chart, then import the study...

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

Login

Login Page - Create Account