iOpen
Syntax
iOpen(Symbol: string, TimeFrame: number, index: number): numberParameters
Return Value
Description
Example
Last updated
iOpen(Symbol: string, TimeFrame: number, index: number): numberLast updated
// Get the open price of the current bar for EURUSD on H1 timeframe
const currentOpen = this.api.iOpen("EURUSD", 60, 0);
// Get the open price from 5 bars ago
const pastOpen = this.api.iOpen("EURUSD", 60, 5);
// Calculate the difference between current and previous bar's open prices
const openDiff =
this.api.iOpen("EURUSD", 60, 0) - this.api.iOpen("EURUSD", 60, 1);
// Check if current bar opened higher than previous bar
if (this.api.iOpen("EURUSD", 60, 0) > this.api.iOpen("EURUSD", 60, 1)) {
console.log("Current bar opened higher");
}