Open
Last updated
Last updated
// Get current bar's opening price
const currentOpen = this.api.Open(0);
// Get previous bar's opening price
const previousOpen = this.api.Open(1);
// Compare current and previous opening prices
const openDiff = this.api.Open(0) - this.api.Open(1);
console.log(
`Price opened ${openDiff > 0 ? "higher" : "lower"} than previous bar`
);
// Get opening prices for last 3 bars
for (let i = 0; i < 3; i++) {
const openPrice = this.api.Open(i);
console.log(`Bar -${i} open price: ${openPrice}`);
}