Rules & Conditions

Almost everything VolNinja does automatically runs on the same idea: a rule. A management rule that takes profit on a position, a template rule that closes a leg, a strategy rule that opens a new trade — they are all built the same way. A rule watches for something to become true, and when it does, it acts.

Because the mechanics are identical everywhere, they are explained once here. The articles for template rules, strategy rules, and a position's own rules cover only what is special about each place; they all point back to this page for how conditions are written.

What a rule is

Every rule has two halves:

  • When — one or more conditions. These decide whether the rule should act.
  • Then — an action. This decides what happens when the conditions are met.

A plain-English example: When the position's profit reaches 50%, then close it. The "when" is a condition; the "then" is an action. This article is about the first half — how you build conditions — because that part works identically no matter where the rule lives. What actions are available depends on the surface, and each rule article covers its own (closing a position, closing or rolling a leg, opening a template, setting a variable, and so on).

A condition, piece by piece

A single condition compares one thing to another:

a field · an operator · a value (or another field)

  • The field is what you're watching — the position's P&L, the underlying price, a leg's delta, the time of day, and many more. Fields come from a searchable catalog, grouped by category, so you pick from what's actually available rather than typing anything by hand.
  • The operator depends on the field's type. Numbers offer greater than, less than, equal, and so on; times offer after, before, and at; yes/no fields offer is and is not.
  • The value is what you compare against — a fixed number, a time, a yes/no — or you can compare one field to another field (optionally scaled by a multiplier), which is how you say things like "the mark is below 30% of the entry credit."

Two ways to build conditions — simple and advanced

Every rule's conditions start from the same list, headed "When ALL of these are true." As the heading says, the rows are combined with and: the rule acts only when every condition holds. (An empty list reads "No conditions — always matches" — the rule's action would run unconditionally.)

The conditions list inside a rule, with plain-language rows and the Add condition / Advanced expression buttons

Two buttons sit below the list:

  • Add condition — the simple editor, for a single straightforward comparison.
  • Advanced expression — the power editor, for anything that needs or, grouping, functions, or arithmetic.

Whichever you use, each finished condition shows up as a plain-language row you can click to edit or remove. You never have to read raw code to know what a rule will do.

Simple conditions

Add condition opens the Edit Condition panel. You choose a Field, pick an Operator, and set what to Compare to — a plain Value, or switch to × field to compare against another field (with an optional multiplier). A live summary at the top restates your condition in words as you build it, so there's no guessing.

The Edit Condition panel, showing Field, Operator and Compare to with a live plain-language preview

Save it and it joins the list as a single readable row. This covers the large majority of real rules — take-profit levels, stop-losses, time-of-day exits — each one a single clear comparison.

Tip

The italic line at the top of the editor is a live preview: it rewrites your condition in plain English as you change the field, operator, or value. If the preview reads the way you'd say it out loud, the condition is right.

Advanced expressions

Some conditions can't be reduced to one row combined with and. When you need "either this or that," grouped logic, a function, or a bit of arithmetic, use Advanced expression to open the Advanced Expression Editor.

The Advanced Expression Editor, showing an ALL of / ANY of tree with color-coded field, value and operator tokens

Here conditions are built as a small tree of colored tokens:

  • A group pill reads ALL of or ANY of — click it to switch a group between and and or. You can nest one group inside another for combinations like "all of these and any of those."
  • Each comparison is a row of badges — a field (blue), an operator, and a value (amber) or another field. Click any badge to change it: pick a different field, type a number, wrap it in a function, or apply math (add, subtract, multiply, divide).
  • + condition and + group extend the tree; the editor keeps the same live Preview at the top and flags any problems, refusing to save until you Fix errors before saving.

Save condition folds the whole expression back into the rule as one advanced row — still shown in plain language, still one click to reopen.

Using variables in conditions

Inside a strategy, the field catalog also includes the strategy's variables — values you define and maintain yourself, plus shared global ones — right alongside the market and position fields. That lets a condition compare a live value to a threshold you control and can change in one place, rather than editing every rule. See strategy variables for how to define and use them.

Field reference

This is the full catalog of fields you can build conditions on. You never type these — you pick them from the searchable list, grouped by category. The picker only offers the fields that apply where you are: a position's or template's rules see the position and leg fields; a strategy's rules see the account and portfolio fields; the market and time fields are available everywhere.

Types decide which operators you get: Number fields offer the full set of comparisons (greater than, less than, equal…); Yes/No and C or P fields offer only is / is not; Time fields offer after, before, and at.

Position fields

Available in a position's rules and a template's rules.

FieldTypeWhat it means
P&L %NumberProfit or loss as a percentage of the premium paid or received at entry.
P&L $NumberProfit or loss in dollars.
DeltaNumberNet position delta — its share-equivalent directional exposure.
Entry PriceNumberNet premium received or paid when the position opened.
Current PriceNumberCurrent mid-market value of the position.
Current Price (Bid)NumberCurrent bid-side value of the position.
Current Price (Ask)NumberCurrent ask-side value of the position.
Hours OpenNumberHours elapsed since the position opened.
Minutes OpenNumberMinutes elapsed since the position opened.
Open LegsNumberHow many of the position's legs are still open.

Leg fields

Available in a position's rules and a template's rules. Choosing a leg field also asks you to pick which leg it refers to.

FieldTypeWhat it means
P&L %NumberThe leg's profit or loss as a percentage of its entry premium.
P&L $NumberThe leg's profit or loss in dollars.
DeltaNumberThe leg's current delta.
GammaNumberThe leg's current gamma.
ThetaNumberThe leg's current theta.
VegaNumberThe leg's current vega.
IVNumberThe leg's current implied volatility.
StrikeNumberThe leg's strike price.
PriceNumberThe leg's current mid price.
BidNumberThe leg's current bid price.
AskNumberThe leg's current ask price.
Entry PriceNumberThe price the leg filled at when it opened.
Type (C/P)C or PWhether the leg is a call or a put.
Is OpenYes/NoWhether the leg is currently open.

Market & time fields

Available everywhere.

FieldTypeWhat it means
LastNumberLast traded price of the underlying. In a strategy, each supported symbol appears by name (for example, SPX · Last).
CloseNumberThe underlying's previous-session closing price.
Current TimeTimeThe current time in ET, on a 24-hour clock.
Minutes Since OpenNumberMinutes elapsed since the 9:30 AM ET open.
Day of WeekNumberThe weekday, where 0 = Monday through 4 = Friday.
Market OpenYes/NoWhether the market is currently open.

Account fields

Available in a strategy's rules.

FieldTypeWhat it means
Total EquityNumberTotal account equity.
Cash BalanceNumberCash balance in the account.
Buying PowerNumberAvailable buying power.
Excess LiquidityNumberEquity minus maintenance margin.
Maintenance MarginNumberMaintenance margin requirement.
Initial MarginNumberInitial margin requirement.
Margin CushionNumberBuffer above the maintenance-margin requirement.
Unrealized P&LNumberUnrealized profit or loss reported by the broker.
Realized P&LNumberRealized profit or loss reported by the broker.
Daily P&LNumberDay's profit or loss reported by the broker.

Portfolio fields

Available in a strategy's rules — these summarize all your open positions at once.

FieldTypeWhat it means
Open PositionsNumberHow many positions are currently open.
Total Unrealized P&LNumberUnrealized profit or loss summed across all open positions.
Total Realized P&LNumberProfit or loss from positions closed today.
Day P&LNumberThe day's total, unrealized plus realized.
Total DeltaNumberCombined delta across all open positions.
Total GammaNumberCombined gamma across all open positions.
Total ThetaNumberCombined theta across all open positions.
Total VegaNumberCombined vega across all open positions.
Total PremiumNumberEntry premium summed across all open positions.
Last Entry Underlying PriceNumberThe underlying's price at your most recent entry.
Last Entry TimeTimeWhen your most recent position opened.
SPX Move from Last EntryNumberHow far the underlying has moved, in dollars, since your most recent entry.

Strategy conditions can also use your own variables and shared global ones — see strategy variables.

Functions

In the advanced editor you can wrap any value in a function: abs (absolute value), min and max (the smaller or larger of two or more values), and round.

The other half — the action

Conditions decide when; the action decides what. Because the available actions differ by where the rule lives, they're covered in the surface-specific articles: template rules, strategy rules, and a position's rules.

Warning

A rule acts on its own — that's the point. When its conditions are met, it runs its action without asking. If that action opens or closes a trade and you're in LIVE mode, it moves real money. Read a rule's conditions carefully before you rely on it, and see Paper vs live.