# GetBufferMax

Finds the maximum value in a buffer within a specified range.

## Syntax

```typescript
GetBufferMax(buffer: number, index1: number, index2: number): number
```

## Parameters

* `buffer` - A number representing the buffer index.
* `index1` - A number representing the start of the range.
* `index2` - A number representing the end of the range.

## Return Value

Returns a `number` representing the maximum value found in the specified range of the buffer.

## Description

The `GetBufferMax` method finds the maximum value in a buffer within the range specified by index1 and index2. This can be useful for scaling or normalizing indicator values.

## Example

```typescript
// Create  buffer
public someBuffer = this.api.CreateIndexBuffer();

// Assign the buffer to index 0
this.api.SetIndexBuffer(0, this.someBuffer)

// Find the maximum value in buffer 0 over the last 20 bars
const max = this.api.GetBufferMax(0, 0, 19)

// Find the maximum value in buffer 1 over a custom range
const startIndex = 10
const endIndex = 50
const maxInRange = this.api.GetBufferMax(1, startIndex, endIndex)

// Use the maximum value for scaling
const scaleFactor = 100 / max
for (let i = 0; i < 20; i++) {
    const scaledValue = this.someBuffer(0, i) * scaleFactor
    this.someBuffer.setValue(i, scaledValue)
}
```


---

# 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/configure_indicator/get-buffer-max.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.
