Init

What is it?

The Init method is called once, right when your custom strategy is created or loaded onto the chart. This is where you set everything up β€” like naming your strategy, creating buffers, creating parameters and registering them, and more.


Syntax

public Init(): void {
    // initialization logic here
}

What Happens in Init

This method is like a constructor for your strategy. Here’s what usually happens inside:

  • Set the name and description of the strategy

  • Create buffers that store the calculated values

  • Create and register input parameters

  • Set the number of plots, line types, and other configurations


Example


Why It Matters

  • Without Init, your strategy won`t have any parameters to work with.

  • Think of it as your setup stage β€” it only runs once when the strategy is loaded.


Pro Tip

Avoid heavy calculations or per-bar logic here. Use OnTick() for that. Init is only for defining the structure and settings of the strategy.

Last updated