SetChartSymbolAndTimeframe

Description

The SetChartSymbolAndTimeframe method changes the symbol and/or timeframe of the current chart.

Syntax

public SetChartSymbolAndTimeframe(symbol: string, period: number): boolean

Parameters

  • symbol: A string representing the trading symbol (e.g., "EURUSD"). Pass empty string to change only timeframe

  • period: A number representing the chart timeframe period

Return Value

Returns a boolean indicating whether the operation was successful.

Example

try {
    // Change both symbol and timeframe
    const success = this.api.SetChartSymbolAndTimeframe('EURUSD', 60)
    if (success) {
        console.log('Chart symbol and timeframe updated successfully')
    }

    // Change only timeframe
    const timeframeOnly = this.api.SetChartSymbolAndTimeframe('', 240)
    if (timeframeOnly) {
        console.log('Chart timeframe updated to H4')
    }
} catch (error) {
    console.error('Failed to update chart:', error.message)
}

Last updated