# iHighest

Returns the index of the bar with the highest value over a specified range.

## Syntax

```typescript
iHighest(symbol: string, timeFrame: number, type: number, count: number, index: number): number
```

## Parameters

* `symbol`: The symbol to get data for
* `timeFrame`: The timeframe of the data (in minutes)
* `type`: The price type to compare (0=OPEN, 1=HIGH, 2=LOW, 3=CLOSE, 4=VOLUME)
* `count`: Number of bars to search through
* `index`: The starting bar index (0 is current/last bar, 1 is previous bar, etc.)

## Return Value

Returns a `number` representing the index of the bar with the highest value. Returns -1 if no valid bar is found.

## Description

The `iHighest` method searches for the bar with the highest value of the specified price type (open, high, low, close, or volume) within a range of bars. The search starts from the specified index and looks back for the specified number of bars. The method is useful for finding local maxima and implementing various technical analysis strategies.

## Example

```typescript
// Find highest high price in last 10 bars
const highestIndex = this.api.iHighest("EURUSD", 60, 1, 10, 0);
if (highestIndex !== -1) {
  const highestPrice = this.api.iHigh("EURUSD", 60, highestIndex);
  console.log(`Highest price: ${highestPrice} at index ${highestIndex}`);
}

// Find highest close in last 20 bars
const highestCloseIndex = this.api.iHighest("EURUSD", 60, 3, 20, 0);

// Find highest volume in last 5 bars
const highestVolumeIndex = this.api.iHighest("EURUSD", 60, 4, 5, 0);

// Check if current bar is highest in last 50 bars
const isNewHigh = this.api.iHighest("EURUSD", 60, 1, 50, 0) === 0;

// Find highest high starting from a specific bar
const startIndex = 10;
const lookback = 5;
const highIndex = this.api.iHighest("EURUSD", 60, 1, lookback, startIndex);

// Get highest price values for different types
const types = [0, 1, 2, 3]; // OPEN, HIGH, LOW, CLOSE
const highestValues = types.map((type) => {
  const idx = this.api.iHighest("EURUSD", 60, type, 10, 0);
  return idx !== -1 ? this.api.iHigh("EURUSD", 60, idx) : null;
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fto-2.gitbook.io/fto-indicators-docs/access-to-bar-arrays/ihighest.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
