Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 16:00:01 +0000



[Programming Help] - Trying to OR(AND a condition and I think I'm wrong.

View Count: 233

[2024-05-20 16:40:57]
C_Money - Posts: 65
On my "Color bar based on alert condition" study, I want to have either condition be true, but not both at the same time:

1. Divergence detector has an up arrow on the current bar and Heiken-Ashi bar is green
2. Divergence detector has an up arrow on the current bar and Heiken-Ashi bar is a very skinny doji with just a small amount of body.

This is what I have and I think it's wrong because I keep getting alerted on bars that are not doji at all:

=OR(AND(ID27.SG4>0,ID18.SG4>ID18.SG4[-1]), AND(ID27.SG4>0),(ABS(ID18.SG1[-1] - ID18.SG4[-1]) / (ID18.SG2[-1] - ID18.SG3[-1]) <.50))

ID27.SG4 = divergence detector up arrow
ID18.SG1 = Heiken Ashi Open
ID18.SG2 = Heiken Ashi High
ID18.SG3 = Heiken Ashi Low
ID18.SG4 = Heiken Ashi Close
[2024-05-20 17:41:42]
emmanuel - Posts: 57
You're looking for an XOR operator, which I don't see available in Sierra Chart's formulas.

You can do some research on XOR to learn how it's constructed, and from that you can troubleshoot your formula.

https://en.wikipedia.org/wiki/XOR_gate
[2024-05-20 18:43:03]
C_Money - Posts: 65
Sorry, now that I think of it. If they are both true at the same time, then that's fine. Do I still need an XOR for that?
[2024-05-20 18:45:14]
ForgivingComputers.com - Posts: 960
As was mentioned by @emmanuel, you are looking for Exclusive OR (XOR: either is true, but not both).

XOR(a,b) = (a && !b) || (!a && b)

1. Divergence detector has an up arrow on the current bar and Heiken-Ashi bar is green

a = AND(ID27.SG4>0,!(ID18.SG4>ID18.SG1))

2. Divergence detector has an up arrow on the current bar and Heiken-Ashi bar is a very skinny doji with just a small amount of body.

Since this cannot be a Green Bar, the Doji is either Open=Close, or Open>Close.

b = AND(!(ID27.SG4>0, ID18.SG4<=ID18.SG1)),(ABS(ID18.SG1 - ID18.SG4 <.50))

[2024-05-21 00:44:41]
Sawtooth - Posts: 4119
Here's another example:
Need a alternative for =XOR

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

Login

Login Page - Create Account