GetChartInformation
Last updated
Last updated
// Get chart information
const chartInfo = this.api.GetChartInformation()
if (chartInfo) {
// Check if chart has valid indices
if (chartInfo.firstIndex >= 0 && chartInfo.lastIndex >= 0) {
// Process only visible bars
for (let i = chartInfo.firstIndex; i <= chartInfo.lastIndex; i++) {
// Your indicator logic here
}
}
// Access chart properties
console.log(`Visible bars: ${chartInfo.firstIndex} to ${chartInfo.lastIndex}`)
console.log(`Bar width: ${chartInfo.barWidth} pixels`)
console.log(`Current zoom: ${chartInfo.currZoom}`)
console.log(`Paint area: ${chartInfo.paintRect.width}x${chartInfo.paintRect.height}`)
}
// Check for zoom level before processing
const chartInfo = this.api.GetChartInformation()
if (chartInfo && chartInfo.currZoom <= 2) {
// Skip processing when zoomed out too much
return
}