Support Board
Date/Time: Sat, 08 Feb 2025 15:48:49 +0000
[User Discussion] - when to use [sc.Index]
View Count: 1416
[2020-07-13 14:14:19] |
User681150 - Posts: 62 |
i am learning the ACSIL language and am trying to understand the why & when to use certain parameters i have this simple function: this FAILS SCFloatArray opens = sc.BaseData[SC_OPEN];
SCFloatArray lasts = sc.BaseData[SC_LAST]; sc.Subgraph[0] = opens - lasts; BUT this works... why do i need to add [sc.Index] to the last line for it to work, but dont need it on first 2 lines?? or why do i need it at all if AutoLoop is set to 1? thanks for an explanation SCFloatArray opens = sc.BaseData[SC_OPEN]; SCFloatArray lasts = sc.BaseData[SC_LAST]; sc.Subgraph[0][sc.Index] = opens[sc.Index] - lasts[sc.Index]; |
[2020-07-13 17:53:58] |
JohnR - User831573 - Posts: 309 |
In the first 2 lines, you are working with/defining the entire array - opens and lasts. To get at a specific bar, is when you use the [sc.Index]. assuming sc.Index = current bar Line 3 says, for the subgraph[0] current bar, plot/output the calculated value of the current bar open - low. Hope that helps, JohnR |
[2020-07-14 07:13:47] |
User907968 - Posts: 826 |
As above, whether autoloop or not, you must pass an index parameter to access an array at a particular index. This page contains relevant information - Working with ACSIL Arrays and Understanding Looping: Introduction The differences between manual and automatic looping are explained in the following articles: https://www.sierrachart.com/index.php?page=doc/ACS_ArraysAndLooping.html# Working with ACSIL Arrays and Understanding Looping: Manual Looping/Iterating |
To post a message in this thread, you need to log in with your Sierra Chart account: