Login Page - Create Account

Support Board


Date/Time: Fri, 26 Apr 2024 19:30:05 +0000



[Programming Help] - SCInputRef variable question...

View Count: 604

[2018-07-02 16:30:32]
User895355 - Posts: 55
Basically, I want to increment MyVar by 1 each time "myCondition" is met. Works fine, except when I reload/recalculate the chart, MyVar does NOT reset to 0, keeps its value, and increments every time I reload/recalculate the chart. What am I missing here?
I have this:


SCInputRef MyVar = sc.Input[0];

if (sc.SetDefaults)
{
sc.AutoLoop = 1;
MyVar.SetInt(0);
return;
}

if (myCondition)
{
MyVar.SetInt(MyVar.GetInt() + 1);
}

[2018-07-09 19:20:02]
User895355 - Posts: 55
Ok, well, I'll answer my own question in case someone else has this issue (please correct if there's another way):

if (sc.IsFullRecalculation)
{
if (sc.Index == 0)
{
MyVar.SetInt(0);
}
}

[2018-07-09 22:46:28]
Sierra Chart Engineering - Posts: 104368
Yes the way you did it in the last post is correct.
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