Support Board
Date/Time: Mon, 10 Feb 2025 15:00:14 +0000
[Programming Help] - formula for a candle body mostly above or below a zero line
View Count: 635
[2020-08-23 07:25:49] |
User164231 - Posts: 278 |
Hi All, I tried but failed to create a formula for SP net issue that triggers whenever the candle is at the zero line, and most of its body is above the zero line per the circled candle on image attached. Appreciate if anyone could help me out here. Thanks. Date Time Of Last Edit: 2020-08-23 07:44:22
|
![]() |
[2020-08-23 12:14:56] |
Sawtooth - Posts: 4173 |
Try this: =AND(ID1.SG1>0,ID1.SG4<0,ABS(ID1.SG1)>ABS(ID1.SG4)) -where ID1 is the bar's study. Reverse the operators for the opposite direction. |
[2020-08-24 16:25:44] |
User164231 - Posts: 278 |
Thanks Tom, your formula works like a charm! However the strange thing is When I reverse the 3 operators it does not work the opposite. I had to do this instead but it could only capture red bars; =AND(ID1.SG1>0,ID1.SG4<0,ABS(ID1.SG1)<ABS(ID1.SG4)) this is intriguing! 😅 |
[2020-08-24 18:10:12] |
Sawtooth - Posts: 4173 |
Sorry, you are correct, you can't reverse all of the operators ;) If you want separate alerts/colors, you'll need two instances of the color bar study, or two studies' Alerts tabs where you can put two separate formulas. Red bars crossing zero from above: =AND(ID1.SG1>0,ID1.SG4<0,ABS(ID1.SG1)>ABS(ID1.SG4)) Green bars crossing zero from below: =AND(ID1.SG1<0,ID1.SG4>0,ABS(ID1.SG1)>ABS(ID1.SG4)) You could combine them into one alert using OR: =OR(AND(ID1.SG1>0,ID1.SG4<0,ABS(ID1.SG1)>ABS(ID1.SG4)),AND(ID1.SG1<0,ID1.SG4>0,ABS(ID1.SG1)>ABS(ID1.SG4))) |
[2020-08-25 13:35:51] |
User164231 - Posts: 278 |
You are a genius! Working awesome now!
|
To post a message in this thread, you need to log in with your Sierra Chart account: