Init
What is it?
The Init
method is called once, right when your custom indicator is created or loaded onto the chart.
This is where you set everything up β like naming your indicator, creating buffers, creating parameters and registering them, and more.
Syntax
What Happens in Init
Init
This method is like a constructor for your indicator. Hereβs what usually happens inside:
Set the name and description of the indicator
Create buffers that store the calculated values
Create and register input parameters like period, color, or line style
Set the number of plots, line types, and other configurations
Example
Why It Matters
Without
Init
, your indicator won't show anything.It's required to tell the system how many lines you draw and what inputs you need.
Think of it as your setup stage β it only runs once when the indicator is loaded.
Pro Tip
Avoid heavy calculations or per-bar logic here. Use Calculate()
for that.
Init
is only for defining the structure and settings of the indicator.
Last updated