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
): voidParameters
bufferIndex- A number representing the index of the buffer to style.type- A value from theTDrawStyleenum specifying how to draw the buffer.style- A value from theTPenStyleenum 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, useSetIndexVisibilityinstead.
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 creationFor algorithmic visibility control - use
SetIndexVisibilityinCalculate()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
SetIndexStyle= Initial setup inInit()onlySetIndexVisibility= Dynamic changes inOnParamsChange()orCalculate()Both methods control visibility, but serve different purposes in the indicator lifecycle
Last updated