TOptValue_LineStyle

What Is It?

TOptValue_LineStyle is a class used to define line style parameters for custom indicators. It allows users to configure line appearance (visibility, color, style, width) through the indicator settings panel.

Use the createTOptValue_LineStyle() method from the api object inside Init() method to create an instance.


When to Use

Use TOptValue_LineStyle when you want to let the user configure line appearance for:

  • Support/resistance levels

  • Trend lines

  • Other visual elements on charts


Syntax

public MyLineStyle!: TOptValue_LineStyle;

public Init(): void {
    // Create the parameter
    this.MyLineStyle = this.api.createTOptValue_LineStyle(isVisible, color, style, width, ignoreColor);

    // Register the parameter
    this.api.RegOption("MyLineStyle", TOptionType.LINE, this.MyLineStyle);
}

Example

In this example:

  • LineStyle allows the user to configure line appearance

  • Inside Calculate(), a horizontal line is created with the configured style

  • The line is positioned at the current bar's close price


Notes

  • Don't forget to register line style parameters using this.RegOption inside the Init method.

  • Use TOptionType.LINE when registering TOptValue_LineStyle parameters.

  • Access properties with this.MyLineStyle.isVisible, this.MyLineStyle.color, this.MyLineStyle.style, this.MyLineStyle.width.

Last updated