-
Any potential updates or changes can be found in HaasOnline Discord server.
Here’s my implementation for a switch-case system.
Usage:
local c = ClosePrices() local len = 20 local indicator = 'sma' local values = switch({ select = indicator, run_funcs = true, cases = { ['sma'] = || SMA(c, len), ['ema'] = || EMA(c, len), ['dema'] = || DEMA(c, len) } }) Plot(0, indicator, values)
If run_funcs = false then you will get the function itself as the return value, and in the case of this example, would run it like this in the plot or wherever:
values().
A better example of run_funcs = false would be this:
local c = ClosePrices() local len = 20 local indicator = 'sma' local cmd = switch({ select = indicator, -- run_funcs = false, <- if not defined, defaults to false cases = { ['sma'] = SMA, ['ema'] = EMA, ['dema'] = DEMA } }) local values = cmd(c, len) Plot(1, indicator, values)