CreateIndexBuffer
Creates a new buffer for storing indicator values.
Important: This method should only be used inside the Init() method during indicator initialization.
Syntax
CreateIndexBuffer(): TIndexBufferParameters
This method does not take any parameters.
Return Value
Returns a TIndexBuffer object that can be used to store indicator values.
Description
The CreateIndexBuffer method creates a new buffer for storing indicator values. Buffers are essential for displaying data on charts and must be properly declared, created, and configured during indicator setup.
Buffer Management Rules:
Declare all buffers as class-level fields using the
!syntaxCreate buffers in
Init()usingCreateIndexBuffer()Register buffer count with
IndicatorBuffers()Assign buffers to indexes with
SetIndexBuffer()Configure buffer appearance with
SetIndexStyle()
See TIndexBuffer for more information about working with indicator buffers.
Proper Buffer Declaration
All buffers must be declared as class-level fields with the non-null assertion operator (!):
Complete Buffer Setup Workflow
Step 1: Declare Buffers (Class Level)
Step 2: Create and Configure in Init()
Step 3: Use Buffers in Calculate()
Buffer Creation Rules
β
Must Be Done in Init()
Create all buffers with
CreateIndexBuffer()Register buffer count with
IndicatorBuffers()Assign buffers to indexes with
SetIndexBuffer()Configure initial styles with
SetIndexStyle()
β Cannot Be Done Outside Init()
Creating new buffers in
Calculate()or other methodsChanging buffer count after initialization
Reassigning buffer indexes during runtime
Complete Example
Key Rules Summary
Declare buffers as class-level fields with
!syntaxCreate buffers only in
Init()usingCreateIndexBuffer()Assign buffers to indexes with
SetIndexBuffer()Configure appearance with
SetIndexStyle()Use buffers in
Calculate()for data storage and retrievalNever create buffers outside
Init()- this will cause errors
Last updated