iVolume
Syntax
iVolume(Symbol: string, TimeFrame: number, index: number): numberParameters
Return Value
Description
Example
Last updated
iVolume(Symbol: string, TimeFrame: number, index: number): numberLast updated
// Get the volume of the current bar for EURUSD on H1 timeframe
const currentVolume = this.api.iVolume("EURUSD", 60, 0);
// Get the volume from 5 bars ago
const pastVolume = this.api.iVolume("EURUSD", 60, 5);
// Calculate the total volume over the last 3 bars
const totalVolume =
this.api.iVolume("EURUSD", 60, 0) +
this.api.iVolume("EURUSD", 60, 1) +
this.api.iVolume("EURUSD", 60, 2);
// Calculate average volume over last 3 bars
const avgVolume = totalVolume / 3;
// Check if current volume is higher than previous bar
if (this.api.iVolume("EURUSD", 60, 0) > this.api.iVolume("EURUSD", 60, 1)) {
console.log("Volume is increasing");
}
// Check for volume spike (2x average)
const isVolumeSpiking = this.api.iVolume("EURUSD", 60, 0) > avgVolume * 2;