High
Returns the highest price for a specific bar.
Syntax
High(shift: number): number
Parameters
shift
: A number representing the shift from the current bar
Return Value
Returns a number
representing the highest price reached during the specified bar.
Description
The High
method returns the highest price reached during a bar at the specified shift from the current bar. The shift parameter determines which bar's high price to return:
0: Current bar
1: Previous bar
2: Two bars ago
And so on
Example
// Get current bar's high price
const currentHigh = this.api.High(0);
// Get previous bar's high price
const previousHigh = this.api.High(1);
// Find highest price over last 3 bars
let highestPrice = this.api.High(0);
for (let i = 1; i < 3; i++) {
const high = this.api.High(i);
if (high > highestPrice) {
highestPrice = high;
}
}
console.log(`Highest price in last 3 bars: ${highestPrice}`);
// Check if current bar made new high
if (this.api.High(0) > this.api.High(1)) {
console.log("New high formed on current bar");
}
Last updated