Support Board
Date/Time: Mon, 25 Nov 2024 00:49:03 +0000
[Programming Help] - ASCII study coding question
View Count: 313
[2024-04-12 18:26:32] |
User395175 - Posts: 87 |
Hi, if i want my study to run only one time when the most recent bar just closed and before new bar added and use the most recent closed bar data, how should i define this condition in code? (i dont want study to be run during study fully recalculation, i want it to run only when the bar is updated during living trading or replay mode), i use auto-looping if (sc.Index == sc.ArraySize - 1) { ... } or if (sc.Index == sc.ArraySize - 2) { ... } ? Date Time Of Last Edit: 2024-04-12 18:28:41
|
[2024-04-12 18:49:29] |
User719512 - Posts: 264 |
See sc.GetBarHasClosedStatus() and ACSIL Interface Members - Variables and Arrays: sc.IsFullRecalculation and the samples under the \SierraChart folder.
|
[2024-04-12 19:57:17] |
User395175 - Posts: 87 |
so im still a little bit confused, to achieve my goal, is my below condition right when using autoloop? if (sc.IsFullRecalculation!=1 && sc.GetBarHasClosedStatus()==BHCS_BAR_HAS_CLOSED { ... } Will it only run the code when recent bar close and before new bar added? I want the study only run one time each time a bar closed during bar updating. Should i add some condition to check sc.Index? like sc.Index == sc.ArraySize - 1) |
[2024-04-12 20:53:48] |
User719512 - Posts: 264 |
See the sample in \SierraChart\ACS_Source\TradingSystem.cpp // Run the below code only on the last bar if (sc.Index < sc.ArraySize-1) return; So that handles that condition. Testing only for when a bar is closed as as you have above: if (sc.IsFullRecalculation!=1 && sc.GetBarHasClosedStatus()==BHCS_BAR_HAS_CLOSED)
Test your code. Write some messages and see if they work as you want them to under live/replay. I think you have all the info you need to succeed here. |
To post a message in this thread, you need to log in with your Sierra Chart account: