GetSymbolName

Returns the name of a symbol by its index.

Syntax

GetSymbolName(pos: number): string

Parameters

  • pos: number - The index of the symbol

Return Value

Returns a string representing the symbol name at the specified index.

Description

The GetSymbolName method retrieves the name of a symbol based on its index in the list of available symbols.

Example

// Get name of first symbol
const firstSymbol = this.api.GetSymbolName(0)
console.log(`First symbol: ${firstSymbol}`)

// Print all available symbols with their indices
const symbolCount = this.api.GetAvailableSymbolCount()
for (let i = 0; i < symbolCount; i++) {
    const symbolName = this.api.GetSymbolName(i)
    console.log(`Index ${i}: ${symbolName}`)
}

// Find specific symbol index
const targetSymbol = 'EURUSD'
for (let i = 0; i < symbolCount; i++) {
    if (this.api.GetSymbolName(i) === targetSymbol) {
        console.log(`${targetSymbol} found at index ${i}`)
        break
    }
}

Last updated