Support Board
Date/Time: Wed, 22 Jan 2025 18:23:40 +0000
Post From: Using persistent data when a study is recalculated - erroneous code provided in the doc
[2018-10-03 13:00:59] |
User470516 - Posts: 78 |
Dear Sierra Chart Team, I am trying to use persistent and, as stated in the documentation, I have noted that they increases when the study is being recalculated. I have therefore used the sc.IsFullRecalculation variable and the code suggested in the doc : https://www.sierrachart.com/index.php?page=doc/ACSIL_Members_Functions.html#scGetPersistentInt: if (sc.IsFullRecalculation)//This indicates a study is being recalculated. { // When there is a full recalculation of the study, // reset the persistent variables we are using sc.GetPersistentInt(0) = 0; sc.GetPersistentInt(1) = 0; sc.GetPersistentInt(2) = 0; sc.GetPersistentInt(3) = 0; } There is an error in the code as it resets the persistent variable at each iteration. it should incorporate something like : if (sc.IsFullRecalculation)//This indicates a study is being recalculated. { if (sc.Index == 0) { // When there is a full recalculation of the study, // reset the persistent variables we are using sc.GetPersistentInt(0) = 0; sc.GetPersistentInt(1) = 0; sc.GetPersistentInt(2) = 0; sc.GetPersistentInt(3) = 0; } } Regards, Laurent |