Input Source
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PineCoders

//@version=5
indicator("Input Source", "", true)

// Input source
// v1, 2022.05.28 14:43
// This code was written using the recommendations from the Pine Script™ User Manual's Style Guide:
//   https://www.tradingview.com/pine-script-docs/en/v5/writing/Style_guide.html

sourceStrToFloat(series string srcString) =>
    float result = switch srcString
        "open"  => open
        "high"  => high
        "low"   => low
        "close" => close
        "hl2"   => hl2
        "hlc3"  => hlc3
        "ohlc4" => ohlc4
        "hlcc4" => hlcc4

// Real `input.source()` call allowing an external input.
float src1Input = input.source(close,  "Input allowing an external input")
// Two more input sources not allowing an external input.
float src2Input = sourceStrToFloat(input.string("high", "Source 2", options = ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4", "hlcc4"]))
float src3Input = sourceStrToFloat(input.string("low",  "Source 3", options = ["open", "high", "low", "close", "hl2", "hlc3", "ohlc4", "hlcc4"]))

plot(src1Input, "src1Input")
plot(src2Input, "src2Input", color.orange)
plot(src3Input, "src3Input", color.green)
