Strategy Rules

A strategy's rules are where its logic lives. Each rule is a When → Then that the strategy evaluates continuously while it's running: when the conditions are true, it runs the rule's actions. The conditions are written with the same editor used everywhere in VolNinja — so this article assumes you've read Rules & Conditions and focuses on what makes strategy rules different.

Two things set them apart from a template's management rules:

  • A strategy rule can run several actions in order, not just one.
  • Those actions reach across your whole setup — opening templates, closing positions, updating variables, even switching other rules on and off.

Where strategy rules live

Open a strategy (its name or the pencil on its card) and find the Rules section; Add rule creates one. Rules are automatically grouped by what they do, so a strategy reads as a plan rather than a flat list:

  • Entry — when to get in (rules that open templates)
  • Exit — when to get out (rules that close positions)
  • Other — variables & switches (everything else)

The Rules section of a strategy, with an Entry rule card showing its conditions and Execute template action

Each card shows the rule's name, its priority (e.g. P50), a per-mode count of how many times it's fired today, and controls to pause/resume, edit, and delete it — above its Conditions and its Action(s).

Anatomy of a rule

Add rule (or a card's pencil) opens the Create Rule sheet: a Name, an optional Description, the Conditions, the Actions, and a set of gates that govern how and when it fires.

The Create / Edit Rule sheet, showing Conditions, the Actions editor, and the priority / cooldown / market-hours gates

The Conditions use the shared editor at strategy scope, which means that alongside market and position fields you can compare against your strategy's variablesmy.*, global.*, and agg.* — right in the picker.

Actions — one rule, several steps

Under Actions (run in order), a rule can hold more than one action; they execute top to bottom, and you reorder them with the arrows. Add action appends one. The action you pick determines what happens:

  • Execute template — open a template to put a trade on. You choose the template and a Multiplier that scales all leg quantities. This is the entry action.
  • Close positions — close matching open positions. You choose Among my positions or all positions, an Execution style (Market or Peg to mid), and an optional Filter for which positions (leave it empty to close every position in scope).
  • Set variable — set a my.* (private) or global.* (shared) variable to a value or an expression, such as my.entries_today + 1 or "risk_off". See Strategy Variables.
  • Enable rule / Disable rule — switch another rule on or off — in this strategy or any other. A rule can even disable itself, which is how you build one-shot behavior.

Each action shows a short hint describing exactly what it does.

Gates — how often and when a rule fires

Below the actions, several settings govern firing:

  • Priority — the order this rule is considered among the strategy's rules (lower first).
  • Cooldown (s) — the minimum number of seconds between firings.
  • Max / day — a cap on firings per day; leave it blank for unlimited.
  • Only during market hours — restrict the rule to regular trading hours.
  • Log only (don't act) — evaluate the rule and record when it would have fired, but take no action.
  • Enabled — turn the rule off without deleting it (the same as the pause control on its card).

Tip

Log only is the safest way to try a new rule. Turn it on and the strategy will note in its Event Log every time the rule's conditions come true — without opening, closing, or changing anything — so you can confirm a rule fires when you expect before you let it act.

Reaching beyond the strategy — with care

Strategy actions are powerful precisely because they aren't limited to this strategy's own trades. Close positions set to all positions can close trades other strategies opened, and Enable/Disable rule can reach rules in any strategy. The editor flags the account-wide close with a warning for that reason.

Warning

An enabled strategy runs these actions on its own. A rule that closes all positions, or toggles rules in other strategies, changes more than the strategy in front of you — and in LIVE mode it does so with real money and no confirmation. Build and prove these rules in Paper first, and use Log only while you're still verifying. See Paper vs live.

Watching rules run

Each rule card shows how many times it has fired today for your current mode, and marks a rule pending while an action is in flight. For the full picture — the runtime view of a running strategy and the account-wide Event Log — see Actions & Runtime.