Login Page - Create Account

Support Board


Date/Time: Fri, 07 Feb 2025 17:07:49 +0000



Auto-coloring of Subgraph based on +/- over another subgraph

View Count: 146

[2024-12-31 04:15:00]
User763335 - Posts: 97
Hello
I have two subgraphs in a study, call it X and MovingAvg(X). I'd like to auto-color X, based on if its above or below MovingAvg(X).
I couldnt find an option under Auto-coloring drop-down. Was looking at Study Subgraphs Subtract/Difference, but not sure how to color based on the difference of this study.
How can I do this?
thanks
[2024-12-31 13:34:41]
emmanuel - Posts: 62
There's a way you can cheat to create the appearance of auto-coloring the subgraph.

Let's say subgraph X is ID1.SG1 and MovingAvg(X) is ID1.SG2.

1. Add a Spreadsheet Formula study to the chart, and set the formula to: IF(ID1.SG1 > ID1.SG2, ID1.SG1, 0)
2. Copy the 1st Spreadsheet Formula study and change the formula to: IF(ID1.SG1 < ID1.SG2, ID1.SG1, 0)
3. Adjust the subgraph colors in both Spreadsheet Formula studies, as needed.

This will produce two new subgraphs rendered in the same chart region, but since they alternatively only produce values when X is above or below MovingAvg(X), and be default subgraphs don't render zero values, you should see what appears to be a single subgraph which changes color.

If you see weird connecting lines, you may need to use "Line skip zeros". See Chart Studies: Avoiding Vertical Joining Line for Study Subgraphs
[2024-12-31 18:11:24]
Sierra_Chart Engineering - Posts: 18330
Instead of doing the above, you also can create your own custom study to do what you need. You can control the color at each chart bar through the Subgraph Data Color array:
ACSIL Interface Members - sc.Subgraph Array: sc.Subgraph[].DataColor[]
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2024-12-31 20:11:03]
User763335 - Posts: 97
Will try, thank you both.
[2025-01-02 16:09:54]
John - SC Support - Posts: 37826
You can also use the "Color Bar Based on Alert Condition" to do what you want. Refer to the following, specifically the section for "Coloring Subgraphs of Other Studies":
Color Bar Based on Alert Condition
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:

Login

Login Page - Create Account