Tool
Branch
logic.branch
Inputs
The first true/false signal — for example a trend filter or a crossover trigger. Read in every mode.
The second true/false signal, used only in ‘and’/‘or’ mode — for example a momentum or session filter. Hidden when mode is ‘if’.
Outputs
A bundle of two true/false lines: ‘true’ carries the mode’s result and ‘false’ carries its exact opposite, one value per bar. Both handles are connectable.
Branch answers one true/false question and gives you both answers at once. The ‘true’ handle fires when the condition holds; the ‘false’ handle fires on every other bar. That pairing is the point — wire ‘true’ into buy and ‘false’ into cancel_buy, and a single node drives both sides of a filter’s exit without a separate Not node.
How it works
Pick a mode. ‘if’ passes input a straight through, so ‘true’ is simply a. ‘and’ is true only when both a and b are true; ‘or’ is true when at least one is. Whatever the mode computes becomes the ‘true’ handle, and ‘false’ is always its exact opposite — the two handles split every bar between them, so they never both fire and never both stay quiet. The mode picker greys out the second input when you select ‘if’.
Modes
Passes a straight through: ‘true’ is a, ‘false’ is every other bar. Input b is ignored.
When to use: Split one existing condition into its pass and cancel sides, e.g. send a trend-up flag to buy and its opposite to cancel_buy.
‘true’ only when both a and b are true; ‘false’ on every other bar.
When to use: Require every condition at once, e.g. trend up AND momentum up before a signal may pass.
‘true’ when at least one of a or b is true; ‘false’ only when neither is.
When to use: Accept any of several setups, e.g. pass on a breakout OR a pullback signal.
Configuration
How the ‘true’ handle is computed: ‘if’ passes a through, ‘and’ needs both inputs true, ‘or’ needs at least one. ‘false’ is always the exact opposite of ‘true’. The second input is hidden in ‘if’ mode.
Connects to
Examples
- Set mode to if, wire a trend-up flag into a, then send ‘true’ to buy and ‘false’ to cancel_buy so the filter reaches a verdict on every bar.
- Set mode to and with trend-up in a and momentum-up in b to pass only when both agree.
Common mistakes
- Wiring ‘false’ into a cancel port without meaning it. ‘false’ fires on every bar the condition does not hold, so routing it to cancel_buy discards the signal immediately — leave ‘false’ unwired if a miss should simply hold and retry on the next bar.
- Leaving b unwired in ‘and’/‘or’ mode: the gate then reads b as false, which pins ‘and’ to false forever and quietly collapses ‘or’ into a plain pass-through of a.