Comparison Node

The Comparison node turns two numbers into a true-or-false condition, like RSI under 30 or price above the 200 EMA. How it works, its settings, and why a condition sometimes never fires.

NodeBy AlgoLiftUpdated 3 min read
On this page 6How it worksExample: only buy in an uptrendSettingsUse something else whenWhen it doesn't behaveGoing further

Most rules in a strategy come down to one number being bigger or smaller than another. RSI under 30. Price over the 200-period average. ADX above 20. The Comparison node is where that happens: give it two numbers and a relationship, and it answers true or false on every bar.

Takes
Two numbers, a and b (up to five)
Gives
True or false, rechecked on every bar
Reach for it
A threshold, or one value sitting above another

How it works

Pick one of six relationships: Greater Than, Less Than, their two "or Equal" versions, Equal, or Not Equal. Wire RSI into a, a Constant of 30 into b, choose Less Than, and the output is true whenever RSI is under 30. Run that into an Entry and you've written a complete entry rule with three nodes.

It's worth being clear about what the output means. A Comparison describes a state, so it stays true for as long as the relationship holds, whether that's one bar or two hundred. That's exactly what you want from a filter ("only while the trend is up"), and usually not what you want from a trigger ("the moment RSI drops under 30"). Triggers have their own node, covered below.

Raise the input count and the node compares each input with the next, so Greater Than over a, b and c means a is above b and b is above c. A stack of three moving averages in order becomes one node. And while an indicator is still warming up, or before a level has formed, the comparison reads false. It won't fire on a value that doesn't exist yet.

Example: only buy in an uptrend

Say you have a long entry on ES 5m that looks fine overall but keeps buying into selloffs. A trend filter takes out the worst of it. Add an EMA with Period 20 and another with Period 50, wire them into a and b of a Comparison set to Greater Than, and AND its output with your signal through a Logic node. The entry can now only fire while the 20 sits above the 50.

For a stricter version, raise the input count to three and add a 200-period EMA as c. Now all three have to line up.

Settings

Comparison
Default Greater Than
Greater Than, Less Than, Greater Than or Equal, Less Than or Equal, Equal or Not Equal.
Inputs
Default 2
From 2 to 5. Each input is compared with the one after it.

Use something else when

You want the moment of a cross
A Comparison is true on every bar after EMA 20 moves above EMA 50. A Crossover is true on the one bar it happens.
A value should sit between two others
There's no "between" setting. Check above the low and below the high, then AND the two.
The rule is about the time of day
Never compare a time as a number. A Time Window handles daylight saving and half days for you.

When it doesn't behave

My Equal comparison is never true

Equal means equal to the last decimal, and computed values like an average, a ratio or a Z-score almost never land exactly on a round number. Compare against a threshold with Greater Than or Equal instead. Equal earns its place with whole numbers: a count, a state, a direction.

“High above the 20-bar high” never fires

If those 20 bars include the current one, the current high can't be above their highest high. At best it's equal. Read the window over completed bars with Price History, which leaves the current bar out by default. The builder flags this case when it sees it.

It's true on almost every bar

That's a state doing a trigger's job. If you meant "when RSI drops under 30" rather than "while it's under 30", use a Crossover against 30.

Going further

To tune a threshold, sweep the Constant wired into b. The Comparison itself has nothing to sweep.

Go easy on stacking conditions, though. Every extra Comparison in an AND is one more knob a backtest can quietly fit to noise. The Inspector's meters show how many bars each condition lets through, which makes it easy to spot one that's doing nothing, or doing everything.

Or ask the copilot