Strategy Variables

Variables let a strategy remember things and share them — a running count of how many trades it has taken today, a flag that says "conditions are risk-off," or a live tally of your open positions. Once defined, a variable can be read (and, for the ones you own, written) inside a strategy's rules, so your automation can react to its own history and to the state of your book, not just to the market.

There are three kinds, and each is referenced in rules by its own prefix:

  • Privatemy.<name> — belongs to a single strategy.
  • Globalglobal.<name> — shared across every strategy.
  • Aggregateagg.<name> — a number computed live over your positions.

All three appear in the field picker right alongside market and position fields when you build a condition, so using one is no different from using P&L or the underlying price — see Rules & Conditions.

Settings every variable shares

Private and global variables share the same three settings:

  • Typenumber, string, or bool (true/false).
  • Reset — when the value returns to its default: daily (each trading day), persistent (kept until something changes it), or manual (only when you or a rule set it). A daily counter uses daily; a long-lived flag uses persistent.
  • Default value — the value it starts from.

Two more things apply everywhere:

  • Paper and Live are separate. A variable holds an independent value for each account, so a counter in paper never bleeds into live. The panels show the value for your current trading mode (with the mode labelled beneath it).
  • Names are identifiers — letters, digits, and underscores only, and can't start with a digit.

Private variables (my.*)

Private variables live inside one strategy. Open a strategy (its name or the pencil on its card) and find the Private variables section; Add variable opens the editor.

The Add variable editor, with Name, Type, Reset and Default value

Give it a Name (referenced as my.<name>), a Type, a Reset policy, and a Default value. Each variable then lists as a row showing my.<name>, its type and reset badges, and its current value for the active mode. Use these for anything a strategy tracks about itself — how many times it has entered today, whether it has already taken profit, a level it computed earlier.

Global variables (global.*)

Global variables are shared: every strategy can read and write them. They live on their own tab, not inside a single strategy — open Automation → Strategies and choose the Global Variables tab.

The Global Variables tab, listing a shared global variable with its type and reset

They carry the same Type, Reset, and Default value settings and are referenced as global.<name>. Reach for a global when strategies need to coordinate — one strategy sets a shared regime flag and others read it, or several strategies draw down a shared daily budget.

Aggregates (agg.*)

An aggregate is a live number computed over your positions — for example, how many of my open positions are up more than 10%. Aggregates live inside a strategy, in the Aggregates section; Add aggregate opens the editor.

The Add aggregate editor, with Population, Positions where, Selector and Field

You define an aggregate in four parts:

  • Name — referenced as agg.<name>.
  • Populationmy positions (this strategy) or all positions (portfolio-wide).
  • Positions where — a condition filter that narrows which positions count, built with the shared condition editor. It covers today's positions, open and closed; filter on is_open to separate the two.
  • Selector — what to compute: count, sum, min, max, last, or first. Everything except count also needs a Field to compute over (sum of P&L, max of delta, and so on).

The editor shows a plain-language summary of each definition — "count of my positions where …" — so you can read back exactly what it measures. Unlike the other two kinds, an aggregate is read-only: it's always computed, never set.

Reading and setting variables in rules

  • Reading — pick my.*, global.*, or agg.* from the field catalog in any condition, and compare it like any other value (see Rules & Conditions).
  • Setting — a strategy's action can update a my.* or global.* variable when a rule fires (incrementing a counter, flipping a flag). See Actions & Runtime. Aggregates need no setting — they recompute on their own.

Removing a variable

Each row has a delete control. If a rule still references the variable, the removal is refused with a note that it may be referenced by a rule — update or remove the rule first, then delete the variable.