Get buffer value

Retrieves a value from a specific buffer at a given index.

Syntax

this.someBuffer.getValue(index);

Parameters

  • index - A number representing the position in the buffer to retrieve the value from.

Return Value

Returns a number representing the value stored at the specified position in the buffer.

Description

The getValue method of a buffer object retrieves a value from a specific buffer at a given index. This is useful for accessing previously calculated values or values from other buffers during indicator calculations.

Example

// Get the value from buffer 0 at the current bar
const currentValue = this.someBuffer.getValue(0);

// Get the value from buffer 0 at the previous bar
const previousValue = this.someBuffer.getValue(1);

// Get a value from another buffer
const signalValue = this.someBuffer.getValue(0);

// Use values in calculations
const difference = currentValue - signalValue;

Last updated