# Volume

Returns the volume for a specific bar.

## Syntax

```typescript
Volume(shift: number): number
```

## Parameters

* `shift`: A number representing the shift from the current bar

## Return Value

Returns a `number` representing the trading volume during the specified bar.

## Description

The `Volume` method returns the trading volume for a bar at the specified shift from the current bar. Volume represents the total amount of trading activity during the bar's timeframe. The shift parameter determines which bar's volume to return:

* 0: Current bar
* 1: Previous bar
* 2: Two bars ago
* And so on

## Example

```typescript
// Get current bar's volume
const currentVolume = this.api.Volume(0);

// Get previous bar's volume
const previousVolume = this.api.Volume(1);

// Calculate average volume over last 3 bars
let totalVolume = 0;
for (let i = 0; i < 3; i++) {
  totalVolume += this.api.Volume(i);
}
const averageVolume = totalVolume / 3;
console.log(`Average volume over last 3 bars: ${averageVolume}`);

// Check for volume spike
if (this.api.Volume(0) > this.api.Volume(1) * 2) {
  console.log("Volume spike detected on current bar");
}
```


---

# 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/volume.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.
