iHigh
Returns the highest price of a bar in the specified symbol's price history.
Syntax
iHigh(Symbol: string, TimeFrame: number, index: number): number
Parameters
Symbol
: The symbol to get data forTimeFrame
: The timeframe of the data (in minutes)index
: The index of the bar (0 is current/last bar, 1 is previous bar, etc.)
Return Value
Returns a number
representing the highest price of the specified bar.
Description
The iHigh
method retrieves the highest price reached during a bar at the specified index from the price history of a given symbol and timeframe. The index parameter uses zero-based indexing where 0 represents the current (most recent) bar.
Example
// Get the high price of the current bar for EURUSD on H1 timeframe
const currentHigh = this.api.iHigh("EURUSD", 60, 0);
// Get the high price from 5 bars ago
const pastHigh = this.api.iHigh("EURUSD", 60, 5);
// Calculate the highest price over the last 3 bars
const highest = Math.max(
this.api.iHigh("EURUSD", 60, 0),
this.api.iHigh("EURUSD", 60, 1),
this.api.iHigh("EURUSD", 60, 2)
);
// Check if current bar's high is a new local high
if (this.api.iHigh("EURUSD", 60, 0) > this.api.iHigh("EURUSD", 60, 1)) {
console.log("New local high formed");
}
// Calculate the average high price of last 3 bars
const avgHigh =
(this.api.iHigh("EURUSD", 60, 0) +
this.api.iHigh("EURUSD", 60, 1) +
this.api.iHigh("EURUSD", 60, 2)) /
3;
Last updated