# Troubleshooting Equality Scans

Equals signs are often used in scan clauses when you are looking for a specific symbol, country, exchange, etc. The equal sign can also be used to look for a specific numeric value in a scan clause, but you may not always get the results you expect. Let's look at an example: In this chart, both the MACD Line (12,26,9) and the MACD Line (20,36,9) for HBI appear to have the same value: 0.800.

## Scanning for Equality

Now let's run a scan to look for symbols where those two MACD Line values are equal to each other:

```[type is stock] and [country is US] and [sma(20,volume) > 40000]
and [close > 21]
and [MACD Line(12,26,9) = MACD Line(20,36,9)]```

If we ran this scan on the same date as the chart, the scan would net us only one result: Despite the fact that the HBI chart showed identical values for these two indicators, HBI does not appear in our scan results.

The reason for this discrepancy is that the values displayed on the chart are rounded to a certain number of decimal points (typically 2 or 3) for display purposes. The values used by the Scan Engine are not rounded to this degree, and the more precise values used by the Scan Engine are often not exactly equal. If the longer-term MACD Line (20,36,9) is 0.8003, and the shorter-term MACD Line (12,26,9) is 0.8004, the Scan Engine does not consider those two values to be equal.

How can we fix our scan so we get the results we expect?

## Scanning for "Close Enough"

When comparing one calculated value to another, it is better to replace the one “equals” clause with two “close enough” clauses like this:

```and [MACD Line(12,26,9) > [MACD Line(20,36,9) - 0.01]]
and [MACD Line(12,26,9) <= [MACD Line(20,36,9) + 0.01]]```

This tells the Scan Engine to return results where one MACD Line is within one cent above or below the other - not identical values, but extremely close to each other. When we run the updated scan, we see that HBI now appears in the scan results: For even greater precision, you could scan for values within one tenth of a cent of each other:

```and [MACD Line(12,26,9) > [MACD Line(20,36,9) - 0.001]]
and [MACD Line(12,26,9) <= [MACD Line(20,36,9) + 0.001]]```

As long as the values are within that small range defined by the two clauses, they are “close enough” to be considered “equal” by our scan.

## Conclusion

The equals sign is great for non-numeric comparisons, but should be used with caution when comparing numeric values. When you do need to compare numbers, it is better to use “close enough” clauses, defining a small range of values so similar that they are essentially equal. 