Operators/probuilder · probacktest · proorder · proscreener

AND

AND in ProBuilder is a logical operator that combines conditions and returns true only when every operand is true. Syntax, precedence and examples.

Syntax

probuilder
condition1 AND condition2

How it works

AND evaluates the conditions on either side and returns true only if both are true. Chaining more conditions with further AND operators tightens the test further, since every linked condition must hold for the result to be true.

Operator precedence matters when AND, OR, and NOT appear in the same expression. NOT binds tightest, then AND, then OR. So a OR b AND c is read as a OR (b AND c). When the intended grouping is not obvious, wrap the parts in parentheses. It makes the logic explicit and removes any doubt about how the expression is parsed.

AND works the same way across ProBuilder indicators, ProScreener, ProBacktest, and ProOrder, because all four evaluate boolean expressions with the same rules.

Examples

Example 1, Two conditions in an indicator (Indicator)

probuilder
// RSI crossing above 50 from below on this bar
myRSIvalue = RSI[14](close)
myValueCondition = 50
IF (myRSIvalue > myValueCondition AND myRSIvalue[1] < myValueCondition) THEN
    signal = 1
ELSE
    signal = 0
ENDIF
RETURN signal

This is the pattern from the official reference. The signal fires only when the current RSI is above 50 and the previous RSI was below it, so both parts of the AND must be true on the same bar.

Example 2, Filtering with several criteria (ProScreener)

probuilder
// Uptrend with volume confirmation
trendUp = close > Average[200](close)
volumeUp = Volume > Average[20](Volume)
cond = trendUp AND volumeUp
SCREENER[cond]

The screener returns only instruments where price sits above its 200-period average and volume is above its 20-period average. Both conditions are required.

Example 3, Guarding an entry (ProOrder)

probuilder
DEFPARAM CumulateOrders = false
// Enter long only when flat and the setup holds
IF NOT LongOnMarket AND close CROSSES OVER Average[50](close) THEN
    BUY 1 CONTRACT AT MARKET
ENDIF

The entry is allowed only when there is no open long position and price crosses above the 50-period average. Combining a position guard with a signal is one of the most common uses of AND.

Common errors and gotchas

  • Precedence with OR. a AND b OR c is parsed as (a AND b) OR c, which is often not what was meant. Add parentheses to state the grouping you want.
  • AND is not bitwise. ProBuilder has no separate bitwise operator. AND always works on boolean conditions, not on numbers treated as bit patterns.
  • Comparing before combining. Each side of AND must itself be a condition. close AND high > low is invalid because close on its own is a value, not a boolean. Write a full comparison such as close > open AND high > low.
  • Over-tightening a filter. Every added AND condition can only reduce the number of matches. A screener that returns nothing often has one condition too many.
  • OR, true when at least one operand is true.
  • XOR, true when exactly one operand is true.
  • NOT, inverts a single condition.
  • IF, the conditional block these operators usually sit in.
  • THEN, ELSE, structure the branches of an IF.
  • CROSSES OVER, CROSSES UNDER, conditions frequently combined with AND.