Support Board
Date/Time: Tue, 04 Mar 2025 19:12:25 +0000
[Programming Help] - ACSIL sc.SetBarPeriodParameters() causes indefinite loading loop
View Count: 602
[2021-12-30 20:39:02] |
tomas262 - Posts: 145 |
Hello, I use the code (see the image) placed before sc.SetDefaults to set range bar size to 30 ticks but it is causing the indefinite reloading of the chart while the period seems to be set correctly as stated in the chart title (30ticks = 7.5 range for NQ) I am slowly getting to the final point where my study is able to adjust according to current market volatility (VXN) :) I would appreciate any hint from anybody, thanks in advance Date Time Of Last Edit: 2021-12-30 20:40:22
|
![]() ![]() |
[2021-12-31 07:56:24] |
User907968 - Posts: 833 |
n_ASCIL::s_BarPeriod NewBarPeriod; if (NewBarPeriod.IntradayChartBarPeriodParameter1 != 30) { . . . sc.SetBarPeriodParameters(NewBarPeriod) } The test 'IntradayChartBarPeriodParameter1 != 30' always returns true. Each time the study is called it is initialized to 0, therefore you are repeatedly calling 'sc.SetBarPeriodParameters(NewBarPeriod)'. Need to call sc.GetBarPeriodParameters to fill data structure, before testing value(s) - as you do in the block at lines 181-191. Date Time Of Last Edit: 2021-12-31 07:57:03
|
[2021-12-31 08:00:23] |
User99735 - Posts: 234 |
Hi, Each time you call sc.SetBarPeriodParameters(NewBarPeriod) the chart will go into recalculation. So after first recalculate the function is called again, and then again in an infinite loop. So add additional checks to ensure that the function sc.SetBarPeriodParameters(NewBarPeriod) is called once only. |
[2021-12-31 15:52:10] |
tomas262 - Posts: 145 |
thank you, it works as expected when I use hard-coded value to compare with but if a refer to another study value using this code ... SCFloatArray VXNChartArray; sc.GetStudyArrayUsingID(VXNChart.GetStudyID(), VXNChartSubgraph.GetSubgraphIndex(), VXNChartArray); float LatestVXNValue = VXNChartArray[sc.Index]; complete code attached as image the indefinite loop occurs again :(( Can the reference to another study value (VXN chart last price in my case) be the problem? I use sc.CalculationPrecedence = LOW_PREC_LEVEL; under sc.SetDefaults Logging outputs correctly though ... Chart: MNQH22-CME [C][M] 3.00 Range #4 | Study: TrendArrowsAdvanced3 | LatestVXNValue: 21.510000; rangeBarSetting (ticks): 12; Current chart setting: 12 | 2021-12-31 09:41:06.978 *
Date Time Of Last Edit: 2021-12-31 16:04:31
|
![]() |
To post a message in this thread, you need to log in with your Sierra Chart account: