Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 19:47:34 +0000



[Programming Help] - ACSIL Help with resetting variables on symbol change.

View Count: 222

[2024-02-16 19:27:58]
User92573 - Posts: 530
Dear Support Board

Can anyone provide some help with resetting variables on symbol change.

I have the following:


// Do Processing

SCString SYM = sc.Symbol.GetChars();  
SCString str_CURRENT_SYM;

if(str_CURRENT_SYM != SYM)
{
  // clear values
}


..... etc. etc.

{
  // code blocks
}

// last line before closing bracket
str_CURRENT_SYM = SYM;

But clearly I've got it wrong.

Any help appreciated.

Many thanks
[2024-02-17 04:20:01]
User43 - Posts: 101
you need to make your str_CURRENT_SYM persistent in order to work as intended.

currently your str_CURRENT_SYM will be a newly initialized on each bar, rendering your
last line before closing bracket obsolete.

see
Persistent Variable Functions
[2024-02-17 16:27:20]
User92573 - Posts: 530
Thank you. Well I used int& and float& in the study for that very reason and completely forgot about the need for a PV with SCString.
Great help thank you!
[2024-02-17 16:34:35]
User43 - Posts: 101
Yeah, the non persistence of variables is a trap I get into myself often enough.
Glad I got you on the right track.

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

Login

Login Page - Create Account