Init
What is it?
Syntax
public Init(): void {
// initialization logic here
}What MUST Be Done in Init
Init1. Create and Register Parameters
// Declare as class-level field
public period!: TOptValue_number;
public showLine!: TOptValue_bool;
public mode!: TOptValue_str;
public Init(): void {
// Create parameters with factory methods
this.period = this.api.createTOptValue_number(14);
this.showLine = this.api.createTOptValue_bool(true);
this.mode = this.api.createTOptValue_str("Simple");
// Register parameters (required for UI visibility)
this.api.RegOption("Period", TOptionType.INTEGER, this.period);
this.api.RegOption("Show Line", TOptionType.BOOLEAN, this.showLine);
this.api.RegOption("Mode", TOptionType.STRING, this.mode);
// Optional: Set parameter constraints
this.api.SetOptionRange("Period", 1, 200);
this.api.SetOptionDigits("Period", 0);
}2. Create and Configure Buffers
3. Set Indicator Properties
What CAN Be Done in Init
InitCore Setup Methods
Buffer Configuration Methods
Parameter Configuration Methods
Recommended Methods
Advanced Configuration Methods
What CANNOT Be Done in Init
Initβ Forbidden Operations
β Wrong Approach
β
Correct Approach
Complete Example
Key Rules Summary
Pro Tip
Last updated