Manage variables
Declare, read, update, rename, and remove Flow variables while preserving their references.
Variables store named values that nodes can read or update during a strategy execution. They are useful for stateful decisions, such as counting matches across evaluations in one run. They do not replace a market-data edge or create a new activation.
Create a variable
- Open Variables.
- Choose the create action.
- Enter a unique, descriptive name.
- Select the value type. New variables use the supported global/flow scope.
- Set the initial value when required.
- Add a short description. The current editor creates persistent global variables; reserved scope or persistence options cannot be selected.
- Save the declaration.
Use a type that matches the values you intend to connect or assign. The declaration is strategy-level configuration; choosing a name in a Read Variable or Set Variable node is a separate step. Before relying on the variable, confirm the node's selected declaration and resolved port type in the Inspector.
Read and update
Add Read Variable to expose the declared value as data. It has no control input: connect its Value output to a compatible data consumer. Add Set Variable to update it from a control path; the write occurs when that path reaches the node. Select the intended declaration in each node. For Set Variable, choose the operation before choosing the value source: Set, Increment, and Decrement can use an active Value data port or supported literal; Toggle applies only to a boolean and does not need a value input.
Rename or remove
Review the usage list before changing a variable. Rename updates supported references through the editor. Delete only after understanding every affected node and recovery shown in the confirmation.
Variables cannot be changed while the graph is read-only or while a conflicting save state blocks editing.
Example: count matching signals
Declare signalCount with type number and initial value 0. Add Set Variable on the control branch after Condition.Match, select signalCount, choose Increment, set the source to Literal, and enter 1. Continue from Set Variable to Alert. A Read Variable node exposes signalCount as a number to a compatible data consumer. Reading does not increment it or start the flow.
These values illustrate the path; an actual Backtest depends on its recorded data and evaluation schedule. If the counter stays at zero, check that Condition.Match reaches Set Variable, that the operation and selected declaration are correct, and that your test period contains a match. If validation reports a type issue, recheck the variable's declared type and whether the Value port or literal is active.
Use numeric variables for Increment/Decrement and a boolean for Toggle. Structured runtime values may require a data input instead of a typed literal. Changing the operation or value source can change the active Value port; review its data edge and validation. Set Variable also exposes New Value as data when another node needs the updated result.
Initial value and lifetime
The declaration and initial value are saved with the strategy. Each new Backtest initializes variables again; a later simulation does not continue the previous run’s counter. Global means shared within the strategy execution, not shared across your account or different strategies. Reserved activation-scoped or legacy declarations may be inspectable without being editable.