Login Page - Create Account

Support Board


Date/Time: Mon, 21 Apr 2025 13:14:32 +0000



[Programming Help] - Support for Logical operators (+/*) for AND/OR

View Count: 145

[2025-02-25 16:04:44]
C_Money - Posts: 79
Do spreadsheet systems support logical operators for boolean evaluations?

Are there any performance savings comparing the two methods below?

// Column 1 (Logical Operators):
= (ID0.SG1@3 > 100) * (ID0.SG2@3 < 50)

// Column 2 (AND() Function):
= AND(ID0.SG1@3 > 100, ID0.SG2@3 < 50)

I've been trying to find a "best practices" or "performance considerations" page on this type of stuff but I'm unable. I have nested if's, or's, and and's all over the place and I'd like to consolidate them in to simpler lines of code.
[2025-02-27 01:10:11]
Jeffrey - Posts: 2248
Do spreadsheet systems support logical operators for boolean evaluations?
Boolean values are treated the same as numbers, where TRUE is the same as 1 and FALSE is the same as 0. Using the multiply operator (*) on two Boolean values is the same as multiplying two numbers. Incidentally, this multiplication does have the same results as an AND operation when used with Boolean values.

Are there any performance savings comparing the two methods below?
I ran some performance tests using the two methods you provided. The results depended on the exact test setup. In some cases using AND was faster, and in other cases using the multiply operator was faster. But in most cases the difference was less than 1 percent. So there is no clear performance advantage to using one method over the other.
[2025-02-27 13:33:33]
C_Money - Posts: 79
Ahhh I see. Good to know, thank you! I have over 130 columns of formulas as I'm referencing 4 higher time frames so, I get considerable lag whenever something gets tagged for full recalculation or if I have to use the chart recalculation study and that timer hits on all 4 charts. At some point I need to convert this to a C++ study..

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

Login

Login Page - Create Account