Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 12:28:51 +0000



[Programming Help] - Referencing 'Color Background Based On Alert Condition' in Simple Alert

View Count: 336

[2023-11-25 16:06:21]
pjk0225 - Posts: 34
I have set up the study "Color Background Based On Alert Condition" with a simple alert that is successfully able to output a background color.
In another study's simple alert on the same chart, I want to reference this Background study as a condition, such as when "Color Background Based On Alert Condition" = "TRUE".
However, this Background study does not seem to output a specific value. I've tried using "ID#.SG1 > 0" and "ID#.SG1 = TRUE" when referencing it but there is no output, and checking the values in "Chart Values For Tools" displays a 0 whether the background is triggered or not.

Is there another way to reference the study "Color Background Based On Alert Condition" correctly?
[2023-11-25 16:15:44]
User431178 - Posts: 543
However, this Background study does not seem to output a specific value
Background subgraph (SG1) outputs 1 when true and 0 otherwise.

Is there another way to reference the study "Color Background Based On Alert Condition" correctly?
You already have the correct method "ID#.SG1 > 0", though not relevant "ID#.SG1<>0" (i.e. non-zero) would also be acceptable.

Check the calculation order / precedence.
Chart Studies: Study Calculation Precedence And Related Issues
[2023-11-26 03:21:54]
pjk0225 - Posts: 34
Firstly, thanks for your input.

Background subgraph (SG1) outputs 1 when true and 0 otherwise.
Does the "chart values tool window" just not display it correctly then? Because it simply outputs "Background: 0" even when true.

You already have the correct method "ID#.SG1 > 0", though not relevant "ID#.SG1<>0" (i.e. non-zero) would also be acceptable.
If this is the case, then that leaves me even more confused, as, if as you said, the study does in fact output "1" when true, then my simple alerts should be showing up correctly.
When testing this, I made sure the study alert works with a simple "=1" test before replacing that code with a simple "ID#.SG1 > 0" test referencing the "Color Background Based On Alert Condition" study, but this does not output anything.

One detail I could mention is that the study "Color Background Based On Alert Condition" I am referencing is itself being called in with the "Study/Price Overlay" study.
So technically my simple alert is referencing "Study/Price Overlay" instead of directly referecing "Color Background Based On Alert Condition".
Could perhaps this be why I am not able to see an output of "1" when the background study is true? Does the "Study/Price Overlay" not output a value of "1" when the "Color Background Based On Alert Condition" study is true?
If this is causing the issue, I wonder what the best workaround for this would be.
[2023-11-29 06:13:10]
j4ytr4der_ - Posts: 938
Keep in mind the Chart Values Window will always show you the value for the last bar in the chart (the "current" bar). If you're trying to look at an older bar, you'll have to use the Tool Value Window. Maybe not related to your issue but I thought I'd mention it.

This could certainly be a precedence issue as well so make sure you try placing your CBBOAC at the top, and bottom, of your list of studies, and see if there's any change to what you get. I use this study quite often and never have the problem you're describing, so it definitely does work.
Date Time Of Last Edit: 2023-11-29 06:13:22

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

Login

Login Page - Create Account