AddLevel
Adds a horizontal level line to the indicator.
Syntax
AddLevel(value: number, style: TPenStyle, width: number, color: string, opacity: number): void
Parameters
value
- A number representing the Y-value where the level should be drawn.style
- A value from the TPenStyle enum specifying the line style.width
- A number representing the line width in pixels.color
- A string hex color value for the level line.opacity
- A number between 0 and 1 representing the opacity of the line.
Return Value
This method does not return a value.
Description
The AddLevel
method adds a horizontal level line to the indicator window. This is commonly used for indicators like RSI or Stochastic to mark overbought and oversold levels.
See TPenStyle for available line styles
Example
// Add an overbought level at 70 (red line)
this.api.AddLevel(70, TPenStyle.SOLID, 1, "#ff0000", 1);
// Add an oversold level at 30 (green line)
this.api.AddLevel(30, TPenStyle.SOLID, 1, "#00ff00", 1);
// Add a middle level with a dashed line (gray line)
this.api.AddLevel(50, TPenStyle.DASH, 1, "#808080", 0.7);
Last updated