Support Board
Date/Time: Fri, 07 Feb 2025 15:23:25 +0000
color bar based on above/below study
View Count: 100
[2025-01-09 17:03:59] |
Boris Libman - Posts: 63 |
I'm trying to use this study to color price bars based on a "flip" of bid/ask ratio study in the same chart. The price bars are in pane 1, the bid/ask ratio study is in pane 2. The price bars are all colored one color that even though the bid/ask ratio oscillates from positive to negative. Please advise
|
[2025-01-09 17:18:30] |
John - SC Support - Posts: 37810 |
The "Color Bar Based on Above/Below Study" looks at a price bar and whether a particular aspect of the bar (High/Low/Open/Close) is above or below another study value. Therefore, it will not work for what you are wanting to do. You would need to use the "Color Bar Based on Alert Condition" study instead and set the alert to be based on the positive or negative value of the ratio you are looking at. Your alert condition would look like the following to color the bar when the ratio is positive: =ID1.SG1 > 0 Where ID1 is the ID of the Bid/Ask Ratio study and SG1 is the first subgraph of that study. You need adjust the ID and subgraph for the particular study you are using. For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2025-01-09 17:29:06] |
Boris Libman - Posts: 63 |
thanks. problem was actually solved by toggling "Based On:" from Main Price Graph to Bid Ask Volume Ratio resulting price bars being painted accordingly when the ratio goes from positive to negative and vice versa. With that said, I would like to incorporate a second study as criteria (supertrend stop) for painting bars where both b/a ratio AND ST stop have to be flip and be aligned for the price bars to be painted. I believe in that case I would use "Color Bar Based on Alert Condition". What would be the syntax entered in the "Alerts" tab and which boxes would need to be checked? |
[2025-01-09 19:20:32] |
John - SC Support - Posts: 37810 |
We do not have enough information to give an absolute formula, and it is not something we do in complex situations like this, but in general here is what you need to think about: - To test if a subgraph has changed state (such as gone from negative to positive) you need to look at the value of the previous bar and then check if it is different from the current bar. An Alert formula if the previous bar was negative and the current bar is positive would be the following: =AND(ID1.SG[-1] < 0, ID1.SG1 > 0) To check either state (going from Negative to Positive and Positive to Negative would be the following: =OR(AND(ID1.SG1[-1] < 0, ID1.SG1 > 0), AND(ID1.SG1[-1] > 0, ID1.SG1 < 0)) As you can see, you can string ANDs and ORs together and have as many tests in each one as you need. For instance, you can then use the above with the following: =AND(ID2.SG1 > L, OR(AND(ID1.SG1[-1] < 0, ID1.SG1 > 0), AND(ID1.SG1[-1] > 0, ID1.SG1 < 0))) Where L is shorthand for the Last price. Refer to the following for information on Alerts: Study/Chart Alerts And Scanning For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
To post a message in this thread, you need to log in with your Sierra Chart account: