GetFibonacciDescription

Returns the description text for a specific level of a Fibonacci object.

Syntax

GetFibonacciDescription(objectName: string, index: number): string

Parameters

  • objectName: string - The name of the Fibonacci object

  • index: number - The index of the Fibonacci level

Return Value

Returns a string containing the description text for the specified Fibonacci level.

Description

The GetFibonacciDescription method retrieves the description text associated with a specific level of a Fibonacci object. This method works with various Fibonacci tool types (retracements, fans, arcs, etc.).

Example

// Get description for a specific Fibonacci level
try {
  const description = this.api.GetFibonacciDescription("MyFibo", 2);
  console.log(`Level 2 description: ${description}`);
} catch (error) {
  console.log("Error:", error.message);
}

// Get descriptions for all levels
try {
  // Assuming 8 standard Fibonacci levels (0-7)
  for (let i = 0; i < 8; i++) {
    const description = this.api.GetFibonacciDescription("MyFibo", i);
    console.log(`Level ${i} description: ${description}`);
  }
} catch (error) {
  console.log("Error:", error.message);
}

// Example with error handling for different scenarios
function getFiboDescription(objectName: string, level: number): string {
  try {
    return this.api.GetFibonacciDescription(objectName, level);
  } catch (error) {
    if (error.message.includes("not found")) {
      return "Fibonacci object not found";
    }
    if (error.message.includes("does not have levels")) {
      return "Object is not a Fibonacci tool";
    }
    if (error.message.includes("out of bounds")) {
      return "Invalid level index";
    }
    return "Unknown error";
  }
}

Last updated