# SetIndexBuffer

Assigns a buffer to a specific index.

## Syntax

```typescript
SetIndexBuffer(bufferIndex: number, buffer: TIndexBuffer): void
```

## Parameters

* `bufferIndex` - A number representing the index to assign the buffer to.
* `buffer` - A [TIndexBuffer](https://fto-2.gitbook.io/fto-indicators-docs/types/index-buffer) object to be assigned to the specified index.

## Return Value

This method does not return a value.

## Description

The `SetIndexBuffer` method assigns a buffer to a specific index. This is necessary after creating a buffer with CreateIndexBuffer to specify which index the buffer should be associated with. The index must be less than the number of buffers specified with IndicatorBuffers.

## Example

```typescript
// Specify that the indicator uses 3 buffers
this.api.IndicatorBuffers(3);

// Create buffers
const upperBuffer = this.api.CreateIndexBuffer();
const middleBuffer = this.api.CreateIndexBuffer();
const lowerBuffer = this.api.CreateIndexBuffer();

// Assign buffers to indices
this.api.SetIndexBuffer(0, upperBuffer);
this.api.SetIndexBuffer(1, middleBuffer);
this.api.SetIndexBuffer(2, lowerBuffer);

// Now the buffers can be used to store indicator values
```
