RealTest User Guide
RealTest User Guide

 

 

Navigation: Realtest Script Language > Syntax Element Details >

Switch

 

 

 

 

Category

General-Purpose Functions

Description

Value switch function

Syntax

Switch(value, match1, value1, match2, value2, ...)

Parameters

value - the value to switch on

match1...matchN - values to compare it to

value1...valueN - value to return for corresponding match

Notes

Switch(Symbol, $AAPL, 1, $GOOGL, 2, $MSFT, 3)

is equivalent to:

Select(Symbol = $AAPL, 1, Symbol = $GOOGL, 2, Symbol = $MSFT, 3)

or to:

if(Symbol = $AAPL, 1, if(Symbol = $GOOGL, 2, if(Symbol = $MSFT, 3)))

As with Select, the final match, value pair can be replaced by a single value to specify what to return if there are no matches, e.g.

Switch(Symbol, $AAPL, 1, $GOOGL, 2, 3)

would return 3 for all other symbols, whereas the prior example would return nan if there were no matches.

Arguments can be numeric or strings. If strings then comparison is case-insensitive.

 

 

 

Copyright © 2020-2025 Systematic Solutions, LLC