Docs / Rule language
Rule language
Common mistakes
The rules that look right and are not, with what they really answered and what to write instead. Every number is a real answer.
| # | Mistake | Instead |
|---|---|---|
| 1 | Using max() for a breakout | Use highest/lowest for breakouts and max/min for "where it stands now". |
| 2 | Expecting a tie to count as true | Give the line some room: C >= 0.98 * max(H, 20), or use the excluding form. |
| 3 | Putting an offset on a function | ref(sma(C, 20), -1). |
| 4 | Looking forward by accident | Offsets that look back are negative: C[-1]. |
| 5 | A window longer than the history | Keep windows under about 1,000 sessions; a year is 252. |
| 6 | Comparing today with an average that includes today | V > 2 * ref(avg(V, 20), -1) compares with the 20 sessions before today. |
| 7 | Mixing and with or without parentheses | Always bracket a mix of and and or. |
| 8 | Mixing units | Check the unit on the function's entry in the reference. |
| 9 | Writing a state field | rsi(C, 14) > 70. |
| 10 | Trusting that an English question became a rule | Check for rule in the answer, or write it: H > highest(H, 252). |
| 11 | Reading an event as a state | Use C > sma(C, 50) for the state, or barssince(crossup(…)) <= 5 for "recently". |
| 12 | Reading a belief as a probability | Use rule beliefs as filters and strength, forecasts as odds: Reading beliefs. |
1. Using max() for a breakout
C > max(C, 20) can never be true, because the window includes today. On XLE, which closed at a 20-session high, it is 0.5 while C > highest(C, 20) is 0.6462.
Instead: Use highest/lowest for breakouts and max/min for "where it stands now".
2. Expecting a tie to count as true
>= and <= answer 0.50 on an exact tie, not a high belief. C >= max(C, 20) can at best tie, because the window contains today: on XLE, at its 20-day high, it is 0.5, and on SPY C >= max(C, 1) (today against itself) is 0.5.
Instead: Give the line some room: C >= 0.98 * max(H, 20), or use the excluding form.
3. Putting an offset on a function
sma(C, 20)[-1] is not valid: Unexpected token '[' at column 11
Instead: ref(sma(C, 20), -1).
4. Looking forward by accident
C[1] is the next bar, which does not exist: C > C[1] on XLE is 0.5.
Instead: Offsets that look back are negative: C[-1].
5. A window longer than the history
About 1,500 sessions are loaded; C > sma(C, 2000) is 0.5 ("not known") on XLE.
Instead: Keep windows under about 1,000 sessions; a year is 252.
6. Comparing today with an average that includes today
On a spike day, today's volume is part of avg(V, 20), which dampens the comparison.
Instead: V > 2 * ref(avg(V, 20), -1) compares with the 20 sessions before today.
7. Mixing and with or without parentheses
and binds tighter. On AAPL, a or b and c is 0.9119 and (a or b) and c is 0.7437.
Instead: Always bracket a mix of and and or.
8. Mixing units
Returns written by hand are fractions (C / C[-1] - 1 > 0.02 is 2%), but roc() and atr_pct() are percents (roc(C, 20) > 5 is 5%).
Instead: Check the unit on the function's entry in the reference.
9. Writing a state field
rsi > 70 reads rsi as a field, and rules on Ora have none: No field "rsi" — this request has no named state, only price bars (O, H, L, C, V and the functions).
Instead: rsi(C, 14) > 70.
10. Trusting that an English question became a rule
"Is it at a 52-week high?" was answered by the forecast model on TSLA (0.533, no rule in the answer), because the compiler did not recognise it as a "now" question.
Instead: Check for rule in the answer, or write it: H > highest(H, 252).
11. Reading an event as a state
crossup(C, sma(C, 50)) is 0.95 only on the day of the cross and 0.05 on every day after, even while price stays above.
Instead: Use C > sma(C, 50) for the state, or barssince(crossup(…)) <= 5 for "recently".
12. Reading a belief as a probability
A rule's 0.70 does not mean a 70% chance of anything; the condition already holds or not. It says how clearly.
Instead: Use rule beliefs as filters and strength, forecasts as odds: Reading beliefs.
Information, not investment advice. Beliefs and probabilities on this page are real responses for the session shown and change with every session.