Skip to content
Black Friday: sale starts November 15th.

Comparison Solver

Comparison solver node

The Comparison solver compares two inputs, Input A and Input B: whether A is above B, below B, or near B, by a distance you choose.

For example: is the bar entirely above the SMA, is a fast moving average at least 5 points above a slow one, or is volume spiking above its average?

Tip

To compare an indicator with fixed levels instead, use the Threshold solver.

Properties tab

Property Inspector tabs, with the Properties tab selected

The essential settings for the node.

Modifiers

Buttons for the most common output modifiers. They change only the selected instance of a node on a Logic Board, so they appear only when a node is selected there, not when a solver is selected in the Solvers panel. That keeps the solver’s original output unchanged everywhere else it’s used, much like changing an SMA’s plot color on one chart leaves it unchanged on your other charts.

Modifiers: the Enabled, Invert and Swap buttons
ButtonWhat it does
EnableTurns the node on or off. When it’s off, the node is left out of the system’s calculations. It still looks connected on the Logic Board, but it’s ignored.
InvertInverts the node’s output. The same calculation as the Inverter function node, without its extra options.
SwapSwaps the outputs: Long becomes Short and Short becomes Long. The same as the Long/Short Modifier function node with Mode: Swap.

Global Properties

These settings apply to every instance of the solver: change one instance and they all change. To change just one, make a copy of the solver. The copy is a separate solver, with a number added to the end of its name.

Behavior

Turns off the Long or the Short output.

Behavior: the Evaluate setting
SettingWhat it does
EvaluateWhich outputs the solver calculates.
Both: Long and Short.
Long only: only Long; the Short output is removed.
Short only: only Short; the Long output is removed.

Input A

The first value the solver evaluates, compared with Input B. Choose a data type in the Type menu; the settings below it change to match.

TypeWhat it evaluates
Indicator ValueAny installed indicator with a plot or Series<T> output, chosen in the Select Indicator window. The default and most used type. Displacement reads the value from a number of bars back.
PriceA bar price (Open, High, Low, Close, or the Body Top, Median or Bottom), optionally processed over a lookback period.
VolumeThe current bar’s volume.
Swing Point PricesPrices from the latest swing highs and lows.
Linear Regression ChannelThe upper, middle or lower line of a regression channel.
Fixed ValueA single value that never changes. Only useful for solvers with two inputs, such as Comparison.

Every type and its settings in full: Data type selection.

Input B

The second value, compared with Input A. It has the same data types and settings as Input A.

Input A and Input B, each with Type, Indicator and Displacement

Output Rules

Output rules decide when the solver gives a Long or Short output. Open the Rules window with the ellipsis (…) button next to Comparison Rules.

Output: Comparison Rules

The Rules window

Where you define the conditions the solver looks for. One solver can combine several rules, so complex conditions don’t need several solvers.

How the Rules window works

Click a rule’s title bar (the strip that says Fixed or Range) to expand or collapse it.

ControlWhat it does
Add Rule menu (top left)Adds a rule. A Fixed rule is the most common: it compares the Input with a value, or with Input B. A Range rule compares the Input with a lower and upper limit, or with a range of distance between Input A and Input B. To use a Range rule instead of the default Fixed rule, delete the Fixed rule, then add a Range rule.
Output Calculation menu (top right)Decides the output when two or more rules are true at the same time. See below.
Settings window (Range rules)Finer control over the values being evaluated. See below.
Delete buttonDeletes the rule. Undo brings it back.

Output Calculation options

OptionOutput
FirstThe output of the first true rule, working down from the top of the list.
LargestThe largest output of all the true rules. For fuzzy logic systems.
SmallestThe smallest output of all the true rules. For fuzzy logic systems.
AverageThe average of the outputs of all the true rules. For fuzzy logic systems.
AdditionThe outputs of all the true rules added together. For fuzzy logic systems.

Range rule settings

SettingWhat it does
Outside / InsideWhether the rule is true inside the range or outside it.
Exclude / IncludeInclude counts the range limits themselves (>= and <=). Exclude doesn’t (> and <).
Fixed Output / Ranged OutputFixed Output is a simple on/off output: 0, or the value on the far right (usually 1). Ranged Output turns on fuzzy logic: two Output fields appear, and when the Input is between the limits, the output is interpolated linearly between those two values.

Fixed rules

A Fixed rule identifies when Input A is above, below or equal to Input B, optionally offset by a distance. The sentence above the settings changes to describe the condition as you edit it.

  1. Input A: its indicator, bar price or value. When both inputs have the same name, “(A)” is added to tell them apart.
  2. The comparison (see the table below).
  3. Input B, with “(B)” added when the names match.
  4. Plus or Minus: adds the offset to Input B or subtracts it. Not shown for = and !=.
  5. The offset distance.
  6. The unit for the offset, see Measuring distance.
  7. The output value when the rule is true. 1 (100% confidence) suits most systems; use a smaller value only when building a fuzzy logic system.
ComparisonTrue when Input A is
=equal to Input B
!=not equal to Input B
>above Input B (plus or minus the offset)
<below Input B (plus or minus the offset)
>=above or equal to Input B
<=below or equal to Input B

For example, Low [ > ] SMA [ Plus ] [ 5 ] [ Points ] is true while the bar’s low is at least 5 points above the SMA.

Range rules

A Range rule identifies when Input A is within a distance range of Input B. For example, a Long rule can be true while the low is between 0 and 5 points above the SMA, and a Short rule while the high is between 0 and 5 points below it.

  1. Input A.
  2. The smaller distance of the range.
  3. The larger distance of the range.
  4. The unit for 2 and 3.
  5. Input B.
  6. The output value when Input A is within the range of Input B. 1 suits most systems.
Ranged Output (fuzzy logic, advanced)

With Ranged Output on in the rule’s Settings menu, two Output fields appear, 6 and 7: the output confidence value when Input A is at the smaller distance (2), and when it is at the larger distance (3). In between, the output is interpolated. If one of them is 1, the other should be less. Only use this when building a fuzzy logic system.

Options tab

Property Inspector tabs, with the Options tab selected

Secondary settings shared by all nodes.

Weight

Changes the node’s final output value. Only needed when designing a fuzzy logic system, or a fuzzy logic part of a system.

How Weight works

Weight changes only the selected instance of a node on a Logic Board. So the controls appear only when a node is selected there, not when a solver is selected in the Solvers panel: a solver’s original output can’t be changed globally.

ControlWhat it does
Multiply OutputMultiplies the node’s internal Long and Short values (set by the Output Rules on the Properties tab) by this number. The final output still can’t go above 1 (see Slider).
SliderLimits the final output to between 0 and 1. The left handle sets a minimum output, given whether or not the condition is true. The right handle sets the maximum; the output is capped there.
Hedge OperationApplies a formula to the internal value.
None: unchanged.
Very: squares it (value²).
Somewhat: takes the square root (√value).

Example: two out of three

Three solvers check three indicator conditions, but only two need to be true. Connect them to an Additive logic node and set each solver’s maximum (the slider’s right handle) to 0.5. When any two are true, the Additive node adds 0.5 + 0.5 + 0 = 1, which means the two-out-of-three condition is met.

Description

Free text for describing what the node does or what it’s for. The Description is shared by every instance of the node, unlike Weight, which is set per instance.

Help tab

Property Inspector tabs, with the Help tab selected

Shows this page for the selected node, inside BloodHound. Click the node’s image at the top of the page to open it in a bigger window. The built-in web viewer needs NinjaTrader 8.0.26.0 or newer.

Tutorial videos

Example: a trend filter for when the entire bar is above or below the SMA 20 (3 minutes).

Examples

Example 1A: A basic trending state (bar above or below the SMA)

Long while the whole bar is above the SMA 14, Short while it is entirely below.

Settings and chart

Input settings

  • Set Input A » Type to Price.
  • Set Price Type Long to Low, and Price Type Short to High. For the whole bar to be above the SMA, its low must be above it; otherwise the bar touches the SMA.
  • Leave Input B as SMA 14.

Rules window

  • No changes needed.

Result

A Long output while the low is above the SMA 14, a Short output while the high is below it, and no output while the bar touches the SMA.

Example 1B: A minimum separation distance

Long while the SMA 14 is at least 5 points above the SMA 50, Short while it is at least 5 points below.

Settings and chart

Input settings

  • Leave Input A as SMA 14.
  • Set Input B to SMA 50.

Rules window

  • Open the Rules window with the ellipsis (…) button next to Comparison Rules, then set the rule as shown. The offset (setting 5) is 5 points.

Result

A Long output while the SMA 14 is 5 points or more above the SMA 50, a Short output while it is 5 points or more below, and no output while they are within 5 points of each other.

Example 1C: An indicator with several plots

Uses the DM indicator’s +DI and -DI plots. A Fixed rule gives clear directional signals, and a Range rule eases the output in and out (0.5 to 1) as the plots separate, to anticipate the start and end of a trend.

Settings and chart

Input settings

  • Set Input A to DM » +DI.
  • Set Input B to DM » -DI.

Rules window

  • Open the Rules window with the ellipsis (…) button next to Comparison Rules, then set the rule as shown.

Result

The indicator’s choppy signals are filtered out: there is no output while the DI plots are within 2 points of each other.

Example 1D: Volume spikes

Long and Short outputs when volume spikes above its moving average. Measuring the distance in ATRs normalizes how big a spike must be.

Settings and chart

Input settings

  • Set Input A » Type to Volume.
  • Set Input B to VOLMA 14.

Rules window

  • Open the Rules window with the ellipsis (…) button next to Comparison Rules, then set the rule as shown.

Result

Outputs on each volume spike above the average.

Example 2: Higher lows and lower highs

Uses the bundled Swing Highs & Lows indicator: Input A reads the current bar, Input B the previous bar, so the solver sees when a swing level steps up or down.

Settings and chart

Input settings

  • Set Input A and Input B to the Swing Highs & Lows indicator, with the same plots.
  • Change its Number of Swings property as shown.
  • Set Input B » Displacement to 1.

Rules window

  • No changes needed.

Result

A Long output when the Widest Bottom plot (red) steps higher, a higher low; a Short output when the Widest Top plot (green) steps lower, a lower high.

Still stuck? Contact support