Login Page - Create Account

Support Board


Date/Time: Fri, 19 Apr 2024 21:47:24 +0000



Using persistent data when a study is recalculated - erroneous code provided in the doc

View Count: 554

[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
[2018-10-03 18:23:45]
Sierra Chart Engineering - Posts: 104368
Yes this does make sense. But the documentation was probably written with manual looping in mind but we will update it anyway.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account