OnShow

What is it?

The OnShow method is called when the indicator is made visible on the chart. This includes the moment it’s re-enabled after being hidden.


Syntax

public OnShow(): void {
    // logic after showing the indicator
}

When and Why to Use It

Use OnShow when you need to:

  • Re-create or re-draw custom chart objects

  • Restore visual elements that were removed or hidden earlier

  • Trigger any logic that should happen only when the indicator is visible

This method is helpful when your indicator includes dynamic elements (like shapes, labels, or highlights) that should appear only when the indicator is active.


Example

public OnShow(): void {
    // Custom method to re-draw label when the indicator is shown
    this.CreateTextLabel("InfoLabel", 0, this.api.High(0), "SMA Active", "blue")
}

Important Notes

  • This method is not called during every tick or calculation β€” only when visibility changes.

  • If your indicator does not rely on custom objects or UI elements, you may not need to implement OnShow.

Last updated