GetSymbolPart ( int position , int position );
Default values:
position: 1
position: 1
Input parameters
Parameter | Default value | Description |
---|---|---|
position | - | Defines number of symbol part to be returned. |
Description
Returns a part of the composite symbol.
When used on a futures chart, GetSymbolPart()
returns the part of the corresponding composite futures symbol with a namespace appended. Namespace is a market identifier code*.
Consider a composite /ES+/YM chart. To find these symbols’ namespace use AddLabel()
:
Example
declare lower;
plot Spreads = close(GetSymbolPart(1)) - close(GetSymbolPart(2));
The code calculates the spread between the first and second parts of the composite symbol.
AddLabel(yes, GetSymbolPart(1) + " + " + GetSymbolPart(2));
The function displays /ES:XCME + /YM:XCBT, where:
- XCME is a namespace reserved for the Chicago Mercantile Exchange.
- XCBT is a namespace reserved for the Chicago Board of Trade.
To avoid unexpected results, use namespaces in string comparisons. For example, to check if a two-part composite symbol has "/ES":
AddLabel(GetSymbolPart(1) == "/ES:XCME" or GetSymbolPart(2) == "/ES:XCME", "Composite symbol contains /ES!");
Note that all parts of a composite symbol are read in alphabetical order. For example, if you choose "KO+GE", it will be read as "GE+KO" by the system.
*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.