Navigation: Realtest Script Language > Syntax Element Details >

SymNum

 

 

 

 

Category

General-Purpose Functions

Description

Find the number of a given symbol, and/or allow dynamic external symbol usage

Syntax

SymNum(symbol)

Parameters

symbol - any formula returning a string or a number

Return Value

The current symbol number of the specified symbol, or 0 if not found

Notes

If the current symbol is MSFT, then $MSFT, Symbol, SymNum(Symbol), SymNum(?Symbol), and SymNum("MSFT") will each return the same number.

SymNum can also be used as the first argument to Extern, for cases where you need to dynamically refer to other symbols.

Extern(SymNum("MSFT"), C) is equivalent to Extern($MSFT, C), but is less efficient, because "MSFT" will be looked up every time it is processed whereas $MSFT is only looked up once, at the start of the test or scan.

A couple of possible use cases:

Test every permutation of a pair-trade concept in a universe of 30 stocks:

Dynamically build specific futures symbol strings:

 

 

 

Copyright © 2020-2024 Systematic Solutions, LLC