Support Board
Date/Time: Wed, 27 Nov 2024 04:51:57 +0000
[Programming Help] - Alert formula for color Background
View Count: 314
[2023-09-17 22:07:37] |
Ticks - Posts: 183 |
I need assistance with an alert formula to color blue the background when the close is above the upper band and have the background remain the blue color until there is a close under the lower band. The background color will switch to a different color. The attached screenshot of the chart with what I have so far and the alert code is below. Upper Band: id6.sg1 Lower Band: id7.sg1 Blue color: Or(C > id6.sg1, C > id7.sg1 )
Pink color: Or(C < id6.sg1, C< id7.sg1)
Date Time Of Last Edit: 2023-09-17 22:08:50
|
Color background1.PNG / V - Attached On 2023-09-17 22:05:03 UTC - Size: 51.61 KB - 74 views |
[2023-09-17 23:57:45] |
Sawtooth - Posts: 4120 |
I need assistance with an alert formula to color blue the background when the close is above the upper band and have the background remain the blue color until there is a close under the lower band.
You need to create a persistent TRUE when the Close is > than the upper band, then release it when the Close is < the lower band.Reverse the operators for the opposite color. The TRUE, and the FALSE, are made persistent by referencing the color background's previous bar in the final 'else'. Blue: =IF(C>ID6.SG1,1,IF(C<ID7.SG1,0,ID8.SG1[-1])) where this color background study is ID8. Pink: =IF(C<ID7.SG1,1,IF(C>ID6.SG1,0,ID9.SG1[-1])) where this color background study is ID9. Date Time Of Last Edit: 2023-09-18 00:04:56
|
[2023-09-18 00:17:38] |
Ticks - Posts: 183 |
@Sawtooth Thank You. I have used persistent in a spreadsheet for trading. But, I didn't know it was possible to set a persistent within a study alert. Hopefully, your code will help other people who don't know either. Thanks again. |
[2023-09-18 00:45:33] |
Ticks - Posts: 183 |
@Sawtooth One more question if you have time. Is it possible to just color the area between the MA lines instead of the background? To have the chart cleaner. Date Time Of Last Edit: 2023-09-18 00:45:43
|
[2023-09-18 02:00:17] |
Sawtooth - Posts: 4120 |
Is it possible to just color the area between the MA lines instead of the background?
You can do it with 6 Formula Columns in the Spreadsheet Study study.To do it without a spreadsheet study, you'd need: - 2 instances of the Color Background Based On Alert Condition study, using the formulas in post #2, both Hidden. - 4 instances of the Spreadsheet Formula study, to only draw the upper and lower bands when each color is TRUE, all Hidden. - 2 instances of the Study Subgraphs Reference study, each referencing a pair of Spreadsheet Formula studies, Draw Zeros set to No. Date Time Of Last Edit: 2023-09-18 02:02:41
|
[2023-09-18 22:43:59] |
Ticks - Posts: 183 |
Update: I have not been able to get the suggestion in post 5 to work. So I will just have to stick with the entire background of the chart being colored. Thanks for all your assistance. Date Time Of Last Edit: 2023-09-23 18:20:29
|
To post a message in this thread, you need to log in with your Sierra Chart account: