Ora
All documentation Overview

Get started

IntroductionQuickstartHow ora-fin1 decidesHow to build with OraUse-case map

Rule language

OverviewGrammarOperators and beliefsPrices and offsetsWindowsIndicatorsSignals and eventsPattern functionsFunction referenceRule libraryCommon mistakesError messagesEarnings and dividend facts

Questions & answers

Questionsyes_no (noul)choicescoreConfidenceThresholds and calibrationStateAsk by symbol

Patterns

Patterns

Actions & workflows

OverviewRules and templatesDestinationsWebhooks and signaturesWorkflows

API reference

POST /v1/systemoneGET /v1/models

Errors & limits

ErrorsRate limitsKnown limitations

Pricing

Pricing

Resources

FAQChangelogModels & versionsCode in 8 languages

Docs / Rule language

Rule language

Grammar

A rule is one expression. It is usually a comparison, or several joined with and and or. Everything below a comparison is arithmetic on whole price series.

rule     := or
or       := and ( "or" and )*
and      := not ( "and" not )*
not      := ( "not" | "!" ) not | compare
compare  := sum ( (">" | ">=" | "<" | "<=" | "==" | "=" | "!=") sum )*
sum      := product ( ("+" | "-") product )*
product  := power ( ("*" | "/" | "%") power )*
power    := unary ( "^" unary )*
unary    := ("+" | "-") unary | primary
primary  := "(" rule ")" | number | price [ "[" offset "]" ] | function "(" args ")"
price    := O | H | L | C | V
offset   := a whole number, e.g. -1 (yesterday)

Precedence, tightest first

LevelOperatorsExample
1( ), function calls, offsetssma(C, 50), H[-1]
2^ power(C / C[-1]) ^ 2
3* / %1.5 * avg(V, 20)
4+ -sma(C, 20) + 2 * atr(14)
5> >= < <= == = !=C > O
6not (or !)not C > sma(C, 50)
7anda and b
8ora or b

and binds tighter than or, so a or b and c means a or (b and c). Use parentheses whenever you mix them; Combining conditions shows the difference on a real symbol.

Lexical rules

CaseKeywords and function names are case-insensitive: AND, Sma(C, 50). Price letters are too: c is C.
NumbersPlain decimals: 70, 1.5, .97. No exponents or thousands separators. Negative numbers work: willr(14) > -20.
Literalstrue and false are 1 and 0.
Equality= and == are the same. ! is the same as not.
SpacesIgnored: C>H[-1] and C > H[-1] are one rule.
OffsetsOnly on the five price letters: C[-1]. For anything else, ref(x, -n).
NamesA name that is not a price letter, a function or a keyword is read as a state field. Rules on Ora have no state fields yet, so rsi > 70 is a 422; write rsi(C, 14) > 70.
Truth inside arithmeticA comparison is 1 or 0 inside a function or arithmetic, so sum(C > C[-1], 10) counts up days. Only the outermost comparisons, joined by and/or/not, become beliefs.

Valid rules

C > H[-1]
O < L[-1] * 0.99 and C > O
(H - L) < lowest(H - L, 6)
sum(C > C[-1], 10) >= 6
rsi(C, 14) < iif(C > sma(C, 200), 40, 30)
crossup(macd(C), macdsignal(C))
hammer() and C > sma(C, 50)

Not valid

RuleWhyWrite instead
sma(C, 20)[-1] > 0Offsets go on price letters onlyref(sma(C, 20), -1) > 0
rsi > 70No state fields on Ora rulesrsi(C, 14) > 70
C > sma(C)Windows need a periodC > sma(C, 50)
C@5m > O@5mDaily bars onlyA daily rule

The exact messages are on Error messages.

Information, not investment advice. Beliefs and probabilities on this page are real responses for the session shown and change with every session.

Create an account Open the Playground Everything here also lives in the console, next to your keys and usage.