GetSymbol

GetSymbol ();

Description

Returns the currently selected symbol.

When used on a futures chart, GetSymbol() returns the corresponding futures symbol with a namespace appended. Namespace is a market identifier code*.

Consider an /ES chart. To find this symbol’s namespace use AddLabel():

Example

declare lower;
plot Diff = close(GetSymbol()) - close("IBM");

This example script plots the difference between Close prices of currently selected symbol and IBM.

AddLabel(yes, GetSymbol()); 

The function displays /ES:XCME, where XCME is a namespace reserved for the Chicago Mercantile Exchange.

To avoid unexpected results, use namespaces in string comparisons:

AddLabel(GetSymbol() == "/ES:XCME", "Chart for /ES!");

*A namespace, or market identifier code (MIC), is a four-letter code assigned by the International Organization for Standardization (ISO) that uniquely identifies trading exchanges and markets, facilitating automated trade processing.