GetPrice
Syntax
GetPrice(priceType: TValueType, shift: number): numberParameters
Return Value
Description
Example
Last updated
GetPrice(priceType: TValueType, shift: number): numberLast updated
// Get different price types for current bar
const openPrice = this.api.GetPrice(TValueType.OPEN, 0);
const highPrice = this.api.GetPrice(TValueType.HIGH, 0);
const lowPrice = this.api.GetPrice(TValueType.LOW, 0);
const closePrice = this.api.GetPrice(TValueType.CLOSE, 0);
// Calculate bar range
const barRange =
this.api.GetPrice(TValueType.HIGH, 0) - this.api.GetPrice(TValueType.LOW, 0);
// Get prices for multiple bars
for (let i = 0; i < 3; i++) {
const open = this.api.GetPrice(TValueType.OPEN, i);
const close = this.api.GetPrice(TValueType.CLOSE, i);
console.log(`Bar -${i}: Open=${open}, Close=${close}`);
}