Boolean Series
A Boolean Series represents a time-aligned sequence of true / false values derived from market data.
Instead of describing how much something moved, boolean series answer yes/no questions about the market.
They are the foundation of signals, conditions, and alarms in the DSL.
Mental Model
If Number Series describe what the market is doing,
Boolean Series describe whether a condition is met.
Examples of questions Boolean Series answer:
- Is price above a moving average?
- Did RSI cross below 30?
- Is momentum increasing?
- Did a breakout just occur?
Every boolean value corresponds to a specific point in time and can be:
- chained
- combined
- used to trigger alarms
Core Characteristics
Boolean Series:
- Are derived from Number Series or other Boolean Series
- Always return
trueorfalseper time step - Can be combined logically (
and,or,not) - Are side-effect free
- Are evaluated lazily like all expressions in the DSL
Categories
Boolean Series expressions are grouped by the type of question they answer.
Comparison
Comparison expressions evaluate relationships between two values.
Typical use cases:
- Threshold checks
- Crossovers
- Relative positioning
Syntax:
number_series.operator.number_series | scalar
Operators:
| Comparator | Meaning | Example |
|---|---|---|
gt | Greater Than | close().gt(100) |
gte | Greater Than or Equal | close().gte(100.5) |
lt | Less Than | close().rsi(21).lt(35) |
lte | Less Than or Equal | close().lte(close().ema(200)) |
eq | Equal | close().eq(16) |
neq | Not Equal | close().neq(16) |
Number Predicates
Number predicates evaluate conditions on a number series and return a boolean series.
They are typically used in comparisons, filters, and signal conditions.
Structure
A numeric predicate is defined by:
- lhs: the left-hand side number series
- predicate: the condition applied to that series
<number_series>.<predicate>
| Predicate | Descriptipn | Example |
|---|---|---|
rising | Returns true if the series is rising for n consecutive points | close().rising(3) |
falling | Returns true if the series is falling for n consecutive points | close().falling(3) |
between | Returns true if values stay between start and end (inclusive) | close().between(30, 70) |
Slope Conditions
Slope conditions evaluate directional changes between two number series and return a boolean series.
They are commonly used to detect crossovers, breakdowns, and trend shifts.
Structure
A slope condition is defined by:
- lhs: the primary number series
- slope: the directional relationship
- rhs: the reference number series
<number_series>.<slope>(<number_series>)
| Slope Type | Description | Example |
|---|---|---|
CrossesAbove | Returns true when lhs crosses above rhs | ema(9).crosses_above(ema(21)) |
CrossesBelow | Returns true when lhs crosses below rhs | ema(9).crosses_below(ema(21)) |
Logical Operations
Logical operations combine boolean series into more complex conditions.
They allow composing simple rules into expressive signal logic.
Structure
A logical operation is defined by:
- lhs: left-hand boolean series
- operator: logical operator
- rhs: right-hand boolean series
<boolean_series>.<operator>.<boolean_series>
| Operator | Description | Example |
|---|---|---|
and | Returns true when both sides are true | rsi(14).lt(30).and(volume().rising(3)) |
or | Returns true when either side is true | close().gte(ema(50)).or(close().gte(sma(200))) |
Boolean Modifiers
Boolean modifiers transform or constrain an existing boolean series.
They are used to add temporal context, duration guarantees, or negation to conditions.
Structure
A boolean modifier is applied directly to a boolean series:
<boolean_series>.<modifier>(params)
| Modifier | Parameters | Description | Example |
|---|---|---|---|
within | n: number of candles | Returns true if the condition occurred within the last n points | close.rsi(21).lte(30).within(3) |
held_for | n: number of candles | Returns true if the condition stayed true for n consecutive points | close.rsi(21).gte(50).held_for(3) |
not | — | Inverts the boolean series | close.rsi(21).lte(30).not() |
