Login Page - Create Account

Support Board


Date/Time: Mon, 16 Jun 2025 14:36:58 +0000



[Programming Help] - Help with syntax for (Color Background Based on Alert Condition).

View Count: 896

[2022-09-19 05:11:49]
2garin - Posts: 188
Good day. There are two conditions:
AND (ID2.SG2[-1]=ID1.SG2[-1], ID2.SG2=ID1.SG2, ID2.SG2>2, ID2.SG1=ID1.SG1=0)
and
ID2.SG2<1

When writing conditions to the indicator separately, the Background is marked correctly.
I want to write down a condition under which the alert (Background) turned on on the first condition and continued until the second condition appeared (the area is marked with black lines).

The expression only marks the first bar
=IF (AND (ID2.SG2[-1]=ID1.SG2[-1], ID2.SG2=ID1.SG2, ID2.SG2>2, ID2.SG1=ID1.SG1=0), 1, IF ( ID2.SG2<1, 0, 0))
image12.png / V - Attached On 2022-09-19 05:10:24 UTC - Size: 3.05 KB - 125 views
[2022-09-19 16:32:51]
Sawtooth - Posts: 4227
You must create a persistent TRUE until the second condition, like this:
=IF (AND (ID2.SG2[-1]=ID1.SG2[-1], ID2.SG2=ID1.SG2, ID2.SG2>2, ID2.SG1=ID1.SG1=0), 1, IF ( ID2.SG2<1, 0, ID3.SG1[-1]))
where ID3 is the Color Background study.

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

Login

Login Page - Create Account