SetIndexDrawBegin

Sets the starting bar for drawing a buffer.

Syntax

SetIndexDrawBegin(bufferIndex: number, paintFrom: number): void

Parameters

  • bufferIndex - A number representing the index of the buffer.

  • paintFrom - A number representing the bar index to start drawing from.

Return Value

This method does not return a value.

Description

The SetIndexDrawBegin method sets the starting bar for drawing a buffer. This is useful for indicators that require a certain number of bars to initialize before they can produce meaningful values. By setting the draw begin point, you can prevent the indicator from displaying potentially misleading values during its initialization period.

Example

// For a 14-period moving average, don't draw the first 13 bars
this.api.SetIndexDrawBegin(0, 13);

// For a 26-period EMA, don't draw until we have enough data
this.api.SetIndexDrawBegin(0, 25);

// For MACD with 12 and 26 periods, don't draw until we have enough data for both
this.api.SetIndexDrawBegin(0, 25); // MACD line
this.api.SetIndexDrawBegin(1, 33); // Signal line (26 + 9 - 1)

Last updated