Get Variable Node

The Get Variable node reads one of your strategy's variables, so a rule can use what a Set Variable stored. What it reads, when, and where it can't go.

NodeBy AlgoLiftUpdated 1 min read
On this page 3How it worksSettingsWhen it doesn't behave

A variable is only useful if something reads it. The Get Variable node is that reader: it outputs the current value of one variable, ready to wire into a Comparison, a Math node or a Logic node like any other value.

Takes
Nothing. It reads a variable
Gives
The variable's current value
Reach for it
A rule depends on something a Set Variable stored

How it works

Pick the variable from the node's dropdown, or skip a step: drag the variable itself out of the Variables section of the node panel and it lands as a Get Variable already pointed at it. A Numeric variable reads as a number. A Boolean one reads as true or false.

It always gives the latest value. Whatever a Set Variable wrote last is what you get, until the next write. Before the first write it gives the variable's Initial Value (0, or false, when that's left empty), and with Parallel on in the run settings each month of history starts over from it. In the usual pattern, a Set Variable wired from an Entry writes when a trade fills, and a Get Variable in the entry rule reads it on every bar after that. If you use 0 to mean "nothing stored yet", give the variable an Initial Value of 0 and test for it with an Equal comparison.

Settings

Variable
The variable it reads. If the variable is deleted, the node says so and the builder won't run the strategy until you pick another.

When it doesn't behave

I can't wire it into a Crossover or a Since

A variable only exists while the engine steps through the data, so the nodes that work over the whole history up front (a Crossover, Since, Capture, a State Machine and the modifiers) can't read it. Compare it with a Comparison instead. If what you really want is a value from an earlier bar, Capture keeps it without a variable.

It reads the old value right after a write

Within one moment, a Get Variable that isn't wired to the Set Variable can run before it or after it. Read on the bars after the write, not on the same print.