Run Timer
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed

//   __    __            __       __  __                  __       __                        __      __    __              __      _______             __    __                                          __ 
//  /  |  /  |          /  |  _  /  |/  |                /  \     /  |                      /  |    /  \  /  |            /  |    /       \           /  \  /  |                                        /  |
//  $$ |  $$ |  ______  $$ | / \ $$ |$$ |____    ______  $$  \   /$$ | __    __   _______  _$$ |_   $$  \ $$ |  ______   _$$ |_   $$$$$$$  |  ______  $$  \ $$ |  ______   _____  ____    ______    ____$$ |
//  $$ |__$$ | /      \ $$ |/$  \$$ |$$      \  /      \ $$$  \ /$$$ |/  |  /  | /       |/ $$   |  $$$  \$$ | /      \ / $$   |  $$ |__$$ | /      \ $$$  \$$ | /      \ /     \/    \  /      \  /    $$ |
//  $$    $$ |/$$$$$$  |$$ /$$$  $$ |$$$$$$$  |/$$$$$$  |$$$$  /$$$$ |$$ |  $$ |/$$$$$$$/ $$$$$$/   $$$$  $$ |/$$$$$$  |$$$$$$/   $$    $$< /$$$$$$  |$$$$  $$ | $$$$$$  |$$$$$$ $$$$  |/$$$$$$  |/$$$$$$$ |
//  $$$$$$$$ |$$    $$ |$$ $$/$$ $$ |$$ |  $$ |$$ |  $$ |$$ $$ $$/$$ |$$ |  $$ |$$      \   $$ | __ $$ $$ $$ |$$ |  $$ |  $$ | __ $$$$$$$  |$$    $$ |$$ $$ $$ | /    $$ |$$ | $$ | $$ |$$    $$ |$$ |  $$ |
//  $$ |  $$ |$$$$$$$$/ $$$$/  $$$$ |$$ |  $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$  |  $$ |/  |$$ |$$$$ |$$ \__$$ |  $$ |/  |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
//  $$ |  $$ |$$       |$$$/    $$$ |$$ |  $$ |$$    $$/ $$ | $/  $$ |$$    $$/ /     $$/   $$  $$/ $$ | $$$ |$$    $$/   $$  $$/ $$    $$/ $$       |$$ | $$$ |$$    $$ |$$ | $$ | $$ |$$       |$$    $$ |
//  $$/   $$/  $$$$$$$/ $$/      $$/ $$/   $$/  $$$$$$/  $$/      $$/  $$$$$$/  $$$$$$$/     $$$$/  $$/   $$/  $$$$$$/     $$$$/  $$$$$$$/   $$$$$$$/ $$/   $$/  $$$$$$$/ $$/  $$/  $$/  $$$$$$$/  $$$$$$$/ 
//                                                                                                                                                                                                          
//                                                                                                                                                                                                          
//
//@version=5
indicator("Run Timer", overlay=true)
key = input.string("TRIAL", title="Key", group="Auth", confirm=true)
trialBars = input.int(5, title="Trial Period (In Bars)", group="Auth")
f_getTimer()=>
    var timestart = timenow
    barcount = ta.barssince(barstate.islastconfirmedhistory)
    mseconds = timenow-timestart
    seconds = mseconds/1000
    minutes = seconds/60
    hours = minutes/60
    days = hours/24
    
    tmSeconds = mseconds%1000
    tSeconds = seconds%60
    tMinutes = minutes%60
    tHours = hours%24
    [days, tHours, tMinutes, tSeconds, tmSeconds, barcount]

[days, tHours, tMinutes, tSeconds, tmSeconds, barcount] = f_getTimer()
validKey = (key == "1234" or nz(barcount,0) <= trialBars)

var timer = table.new(position=position.top_center, columns=10, rows=1, border_width=0)
backgroundColor = validKey? color.green : color.red
table.cell(table_id=timer, column=0, row=0, text=str.tostring(days, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
table.cell(table_id=timer, column=1, row=0, text="/", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
table.cell(table_id=timer, column=2, row=0, text=str.tostring(tHours, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
table.cell(table_id=timer, column=3, row=0, text=":", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
table.cell(table_id=timer, column=4, row=0, text=str.tostring(tMinutes, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
table.cell(table_id=timer, column=5, row=0, text=":", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
table.cell(table_id=timer, column=6, row=0, text=str.tostring(tSeconds, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
table.cell(table_id=timer, column=7, row=0, text=".", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
table.cell(table_id=timer, column=8, row=0, text=str.tostring(tmSeconds), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)