> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# ApproxCompare()

## Definition

Compares two double or float values for equality or being greater than / less than the compared to value.

Comparing for being greater than / less is done using an epsilon value of 1E19

## Method Return Value

An **int** value representing the outcome of the comparison. Returns 0 if values are equal, 1 if value1 is greater than value2. -1 if value1 is less than value2.

## Syntax

`this.ApproxCompare(this double double1, double double2)`

`this.ApproxCompare(this float float1, double float2)`

## Parameters

| Parameter        | Description                                             |
| ---------------- | ------------------------------------------------------- |
| double1 / float1 | First value to compare against (not actually passed in) |
| double2 / float2 | Second passed in value to compare against               |

Main use would be using it for equality comparisons to circumvent running into floating point considerations, value compares for \< or > could be usually done more straightforward directly.

## Examples

```csharp
// Build the High / Low difference and if 0 sets the indicator main Value series to 0
if ((High[0] - Low[0]).ApproxCompare(0) == 0)
   Value[0] = 0;
```