Watermark Light - JD
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Duyck

//@version=5
indicator("Watermark Light - JD", shorttitle = "Watermark Light", overlay = true)

// Inputs
//{
wm_size     = input.string(size.huge, 
                       title = "watermark size",
                       options = [size.tiny, size.small, size.normal, size.large, size.huge],
                       inline = "WM")
wm_col      = input.color (color.new(color.gray, 60), 
                       title = "",                                
                       inline = "WM")
wm_posV     = input.string("top",                 
                       title = "",
                       options = ["top", "middle", "bottom"],                                
                       inline = "WM")
wm_posH     = input.string("center", 
                       title = "",
                       options = ["left", "center", "right"],                                
                       inline = "WM")
slot1       = input.string("Timeframe", options = ["Timeframe", "Ticker", "Custom Text", "Empty"])
slot2       = input.string("Ticker",    options = ["Timeframe", "Ticker", "Custom Text", "Empty"])
slot3       = input.string("Empty",      options = ["Timeframe", "Ticker", "Custom Text", "Empty"])
custom_txt  = input.string("custom text", 
                       title = "custom text")

//}

// Set Watermark
//{
var watermark = table.new(wm_posV + "_" + wm_posH, 1, 1)

period = timeframe.period
string watermark_txt = ""
string TF_txt        = ""
string Ticker_txt    = ""

TF_txt := switch
    period == "S"     => "1S"
    period == "60"    => "1H"
    period == "120"   => "2H"
    period == "180"   => "3H"
    period == "240"   => "4H"
    period == "360"   => "6H"
    => period + (timeframe.isminutes ? "M" : "")

Ticker_txt := ((syminfo.type == "crypto" or syminfo.type == "forex") ?
              (syminfo.basecurrency + "/" + syminfo.currency) :
               syminfo.ticker)

slot1_txt = switch slot1
    "Timeframe"     => TF_txt
    "Ticker"        => Ticker_txt
    "Custom Text"   => custom_txt
    "Empty"         => ""

slot2_txt = switch slot2
    "Timeframe"     => TF_txt
    "Ticker"        => Ticker_txt
    "Custom Text"   => custom_txt
    "Empty"         => ""

slot3_txt = switch slot3
    "Timeframe"     => TF_txt
    "Ticker"        => Ticker_txt
    "Custom Text"   => custom_txt
    "Empty"         => ""

watermark_txt := 
                                 slot1_txt +
 (slot1_txt == "" ? "" : "\n") + slot2_txt +
 (slot2_txt == "" ? "" : "\n") + slot3_txt

//
if barstate.isfirst
    table.cell_set_text      (watermark, 0, 0, text       = watermark_txt)
    table.cell_set_text_color(watermark, 0, 0, text_color =  wm_col)
    table.cell_set_text_size (watermark, 0, 0, text_size  = wm_size)
//}