SetIndexStyle

Sets the visual style for a buffer.

Important: This method should only be used inside the Init() method for initial buffer configuration.

Syntax

SetIndexStyle(
    bufferIndex: number,
    type: TDrawStyle,
    style: TPenStyle,
    width: number,
    clr: string,
    isVisible?: boolean
): void

Parameters

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

  • type - A value from the TDrawStyle enum specifying how to draw the buffer.

  • style - A value from the TPenStyleenum specifying the line style.

  • width - A number representing the line width in pixels.

  • clr - A string hex color value for the buffer.

  • isVisible - (Optional) A boolean for initial visibility setup only. For algorithmic visibility control, use SetIndexVisibility instead.

Return Value

This method does not return a value.

Description

The SetIndexStyle method sets the visual appearance of a buffer on the chart during indicator initialization. This includes the drawing style (line, histogram, etc.), line style (solid, dashed, etc.), width, color, and initial visibility.

Usage Guidelines:

  • Use in Init() only - for setting up buffer appearance during indicator creation

  • For algorithmic visibility control - use SetIndexVisibility in Calculate() based on conditions/calculations

See TDrawStyle for available drawing styles, TPenStyle for line styles

Visibility Parameter vs SetIndexVisibility

Initial Setup (in Init())

Use the isVisible parameter in SetIndexStyle for setting the initial visibility state:

Dynamic Changes (in OnParamsChange() or Calculate())

Use SetIndexVisibility for algorithmic visibility control:

Example

Key Rules

  1. SetIndexStyle = Initial setup in Init() only

  2. SetIndexVisibility = Dynamic changes in OnParamsChange() or Calculate()

  3. Both methods control visibility, but serve different purposes in the indicator lifecycle

Last updated