Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 14:42:51 +0000



[Programming Help] - Study alert formula that triggers background Red, Blue, or nothing

View Count: 170

[2024-02-29 22:56:42]
User14953 - Posts: 236
How to combine two strings into a single 'Color Bar Based on Alert Condition' study that triggers background 'Blue' to one, or 'Red' to the other, or nothing if neither?
=AND(O<C[-1] , C>O[-4])
=AND(C<O[-1] , O>C[-4])
Date Time Of Last Edit: 2024-02-29 22:58:14
[2024-03-01 02:12:49]
cmet - Posts: 551
If you're looking to use the Color Bar Based on Alert Condition study, pretty sure you need to use two copies, one for the blue bg, one for the red. There is no syntax for the draw styles/colors (to my knowledge).

To combine them into a single statement, use OR:

=OR(AND(O<C[-1] , C>O[-4]), AND(C<O[-1] , O>C[-4]))
[2024-03-01 14:49:28]
Sawtooth - Posts: 4120
How to combine two strings into a single 'Color Bar Based on Alert Condition' study that triggers background 'Blue' to one, or 'Red' to the other, or nothing if neither?
You would need to use two instances of the color bar study, one for each color.

However, if you want to only use one instance of a study for both colors, use the Spreadsheet Formula study with this formula in its Formula field:
=IF(AND(O<C[-1] , C>O[-4]),1,IF(AND(C<O[-1] , O>C[-4]),-1,0))
- Set the Chart Region to 1
- Set the Draw Style to Color Bar
- Set the Auto-Coloring to Based On +/-

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

Login

Login Page - Create Account