Login Page - Create Account

Support Board


Date/Time: Mon, 29 Apr 2024 19:45:44 +0000



[User Discussion] - Know what Arrays contain data

View Count: 829

[2020-07-13 15:39:07]
User681150 - Posts: 62
i wanted to use this MACD function to understand how to access the arrays and knowing which arrays the data exist in... please correct any errors in the words i use.

a Subgraph has 12 arrays. this macd stores the 3 data arrays in sc.Subgraph[0]. you can access and plot each data array by accessing
individual arrays of sc.Subgraph[0].

- Why doesn't the first variable MACD start with Arrays[0] (isnt it zero based? isnt this the proper way to access that data array)
- Why does the second variable MACD MovingAverage use .Arrays[2] and not .Arrays[1]

with these functions that output multiple arrays... how do i know what array holds what?? in the documentatio is says
For this function, sc.Subgraph[].Arrays[0-3] (Extra Arrays) are used for internal calculations and additional results output.

any help with a little explanation would be appreciated... thanks


sc.MACD(sc.BaseData[SC_LAST], sc.Subgraph[0], 5, 10, 10, MOVAVGTYPE_SIMPLE);

//Access the individual lines
float MACD = sc.Subgraph[0][sc.Index]; //Access the study value at the current index

float MACDMovingAverage = sc.Subgraph[0].Arrays[2][sc.Index];

float MACDDifference = sc.Subgraph[0].Arrays[3][sc.Index];

//Copy to Visible Subgraphs
sc.Subgraph[1][sc.Index] = MACDMovingAverage;
sc.Subgraph[2][sc.Index] = MACDDifference;

Date Time Of Last Edit: 2020-07-13 15:57:20
[2020-07-14 07:29:25]
User907968 - Posts: 802
Why doesn't the first variable MACD start with Arrays[0]

Bacause MACD is stored in the main data array( sc.Subgraph[].Data[] ) not in the extra arrays ( sc.Subgraph[].Arrays[][] ) -
ACSIL Interface Members - sc.Subgraph Array: sc.Subgraph[].Data[] / sc.Subgraph[][]
ACSIL Interface Members - sc.Subgraph Array: sc.Subgraph[].Arrays[][]

- Why does the second variable MACD MovingAverage use .Arrays[2] and not .Arrays[1]

with these functions that output multiple arrays... how do i know what array holds what??

In this example you can infer from the code example and explanation that .Arrays[0] and .Arrays[1] contain internal calculation data, as it is shown that .Arrays[2] and .Arrays[3] contain the MACDMovingAverage and the MACDDifference

There are often examples of how to use these functions in the \sierrachart\acs_source folder
[2020-07-14 15:43:39]
User681150 - Posts: 62
so the first variable listed as a float (MACD) is not the MACD signal line? so there are only 2 subgraphs in your sc.MACD and no signal?

//Access the individual lines
float MACD = sc.Subgraph[0][sc.Index]; //Access the study value at the current index

do you even need this line in the example? if sc.MACD already outputs to sc.Subgraph[0] cant you leave out the float MACD = sc.Subgraph[0][sc.Index]; from the code?

just trying to understand the logic. the documentation is all over the place in explaining acsil
[2020-07-14 17:52:09]
User907968 - Posts: 802
so the first variable listed as a float (MACD) is not the MACD signal line? so there are only 2 subgraphs in your sc.MACD and no signal?
No, all I am saying is MACD is stored in sc.Subgraph[].Data[] (or if you prefer shorthand sc.Subgraph[][] ) as opposed to being in the extra arrays ( sc.Subgraph[].Arrays[][] )

do you even need this line in the example? if sc.MACD already outputs to sc.Subgraph[0] cant you leave out the float MACD = sc.Subgraph[0][sc.Index]; from the code?

If you don't need to access that particular data in your code, then no, you would not need that line, as the subgaph is already populated by sc.MACD function. It is only an example of how to access the data.
[2020-07-15 17:08:32]
User681150 - Posts: 62
ive tested the code with and without

float MACD = sc.Subgraph[0][sc.Index]; //Access the study value at the current index

and it works exactly the same, it seems it is redundant since the data is captured in the sc.MACD() function

correct? (just trying to learn the logic)

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

Login

Login Page - Create Account