Support Board
Date/Time: Sat, 01 Mar 2025 10:41:58 +0000
Post From: Accessing persistent variables from another study on recalc
[2021-09-18 18:50:39] |
User920967 - Posts: 62 |
I have a study in which I define a persistent variable to be accessed by another study. For the sake of this example that variable is set to equal the current index on the chart, sc.Index. The expected behavior is that this value updates with each new bar. I have subgraphs on both studies outputting the variable's value for comparison. During recalculation, sc.GetPersistentIntFromChartStudy exclusively returns the final value for the persistent variable, in this case the last index on the chart. This is true for all bars on the chart. The 'source study', meanwhile, outputs the index corresponding to each new bar, as expected. I've used sc.Index here for simplicity, but pattern holds true for other variables. Is this the expected behavior for sc.GetPersistentIntFromChartStudy during recalculation? i.e. Will this only return the value corresponding to the final bar on the chart? Thanks in advance, all help is very much appreciated. Source study (ID3) int& idx = sc.GetPersistentInt(120); idx = sc.Index; idx_sg[sc.Index] = idx; //Outputs the current index on both recalc and replay Destination study PV_sg[sc.Index] = sc.GetPersistentIntFromChartStudy(1, 3, 120); //Outputs the final bar's index |