Done

What is it?

The Done method is called once, after the indicator has finished calculating all bars. It marks the end of the calculation cycle and is typically used for final steps or cleanup.


Syntax

public Done(): void {
    // logic after finishing the calculation
}

When and Why to Use It

Use Done when you need to:

  • Perform post-processing after all Calculate() calls are complete

  • Draw or update custom chart objects that rely on full data

  • Clean up temporary data or buffers

  • Log or store final values

This method is especially useful if your indicator logic depends on seeing the entire dataset.


Example

public Done(): void {
    // Draw a horizontal line based on final SMA value
    const lastIndex = 0
    const finalValue = this.SMA.getValue(lastIndex)
    
    // custom method CreateHorizontalLine
    this.api.CreateHorizontalLine("FinalSMA", finalValue, "red") 
}

Important Notes

  • Done is called after all bars have been processed in Calculate().

  • It runs once per full calculation cycle β€” not on every tick.

  • It’s safe to use this method to add chart decorations, logs, or summary calculations.

Last updated