Login Page - Create Account

Support Board


Date/Time: Mon, 29 Apr 2024 10:51:02 +0000



[Programming Help] - Color bar

View Count: 1437

[2017-09-04 09:21:09]
EuropeanTrader - Posts: 290
Hi,
does anyone maybe know how I can color bar based on 2 simple criteria that must be met simultaneously?

1. EMA is rising
2. MACD slow line is rising

That's all. If this is met, bar should be colored green and vice versa for short of course (if EMA and MACD slow line are falling, bar is red).

Thank you for your help!
imageAUDCAD [M] Daily #2 2017-09-04 11_18_38.279.png / V - Attached On 2017-09-04 09:21:04 UTC - Size: 17.84 KB - 274 views
[2017-09-04 14:36:07]
Sawtooth - Posts: 3982
You'll need two instances of the Color Bar Based On Alert Condition study, one for each color/direction.

Try this:
Put these formulas on the alerts tab of the respective color bar study:

Green bar:
=OR(
AND(ID1.SG1>ID1.SG1[-1],ID2.SG2[-2]>ID2.SG2[-1],ID2.SG2>ID2.SG2[-1]),
AND(ID1.SG1[-2]>ID1.SG1[-1],ID1.SG1>ID1.SG1[-1],ID2.SG2>ID2.SG2[-1])
)
Red bar:
=OR(
AND(ID1.SG1<ID1.SG1[-1],ID2.SG2[-2]<ID2.SG2[-1],ID2.SG2<ID2.SG2[-1]),
AND(ID1.SG1[-2]<ID1.SG1[-1],ID1.SG1<ID1.SG1[-1],ID2.SG2<ID2.SG2[-1])
)
where the EMA is ID1 and the MACD is ID2; edit as needed.

These formulas will color the price bar at the first occurrence of both lines sloped in the same direction.

Limitation: a missed coloring might occur if any line segments are equal to the previous.
The solution to this is to use different formulas in a spreadsheet study, as in this example in post #6:
alert condition kijun sen
[2017-09-04 17:37:33]
EuropeanTrader - Posts: 290
Thank you!!! I appreciate it
[2017-09-06 13:32:53]
EuropeanTrader - Posts: 290
Is there also a way that bar keeps getting colored as long as the condition is true (not only the first occurence)? Thank you.
imageEURJPY [M] Daily #6 2017-09-06 15_32_40.530.png / V - Attached On 2017-09-06 13:32:50 UTC - Size: 94.67 KB - 275 views
[2017-09-06 13:43:34]
Sawtooth - Posts: 3982
What do you want to do when neither are TRUE?
Do you want a third color, or do you want to continue the green until a red, and continue a red until a green?
[2017-09-08 06:15:55]
EuropeanTrader - Posts: 290
When neither are TRUE, I just thought to keep it like it is, nothing, normal bars as defined in Sierra.

Purpose of coloring is only to highlight some strong impulses/trends on this time frame so one can trade in the direction of that trend on much lower time frame.

I hope I understood you correctly.

Thank you
[2017-09-08 14:23:17]
Sawtooth - Posts: 3982
Try these, respectively:
=AND(ID1.SG1>ID1.SG1[-1],ID2.SG2>ID2.SG2[-1])
=AND(ID1.SG1<ID1.SG1[-1],ID2.SG2<ID2.SG2[-1])

If these don't do what you want, you might need to use a spreadsheet study.
[2017-09-08 17:37:18]
EuropeanTrader - Posts: 290
They work !
Thank you again

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

Login

Login Page - Create Account