Scrolling Watermark
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SamRecio

//@version=5
indicator("Scrolling Watermark", shorttitle = "📜", overlay = true)

//Inputs
text_input = input.string("I💙TradingView ", title = "Text", inline = "1", group = "Text Settings")
scroll = input.string("Left", options = ["Left","Right"], title = "Scroll", inline = "1", group = "Text Settings")
txtcolor = input.color(color.white, title = "", inline = "1", group = "Text Settings")
tl1 = input.string("bottom", title = "Table Location", options = ["top", "middle", "bottom"], group = "Table Settings", inline = "1")
tl2 = input.string("right", title = "", options = ["left", "center", "right"], group = "Table Settings", inline = "1")
tsize = input.string("normal", title = "Table Size", options = ["small", "normal", "large", "huge"], group = "Table Settings", inline = "2")
tblcolor = input.color(color.rgb(0,0,0), title = "Table Color", group = "Table Settings", inline = "2")
//BTC Pulling in BTC data and plotting it to force the indicator to update at every price change of BTC. This means we get more consistent updates from the indidcator, which makes it move smoother across all tickers.
btc = request.security("COINBASE:BTCUSD","",close)
plot(btc, display = display.none, editable = false)
//Main Logic and scrolling functionality.
// -Move first letter to the end (Left) or Last letter to the front. (Right)
//
varip lot = str.split(text_input,"") //Turns our Text input into an array of letters ex. [I,💙,T,r,a,d,i,n,g,V,i,e,w, ] Spaces are included in this array.
varip string output = na //creates an assignable output string variable
if scroll == "Left"
    temp = array.get(lot,0) // assigns "temp" the value of the first letter in the array.
    array.remove(lot,0)// removes the first value of the array.
    array.push(lot,temp)// adds out "temp" value (previously the 1st value in the array), to the end of the array.
    output := na// clears the current value of output because we are generating an entirely new output every tick.
    for i = 0 to array.size(lot)- 1 // for every letter in our array
        output := output + array.get(lot,i) // add it to our output string (ex. t + e + s + t)
if scroll == "Right"
    temp = array.get(lot,array.size(lot) - 1) // assigns "temp" the value of the last letter in the array.
    array.remove(lot,array.size(lot) - 1) // removes the last value of the array.
    array.unshift(lot,temp) // adds out "temp" value (previously the last value in the array), to the beginning of the array.
    output := na
    for i = 0 to array.size(lot)- 1
        output := output + array.get(lot,i)
//Displaying the table.
var table t1 = table.new(tl1 +"_" + tl2,1,2)
table.cell(t1,0,0,text = str.tostring(output), text_size = tsize, bgcolor = tblcolor, text_color = txtcolor)
