xmd79

Run Timer

Oct 9th, 2021
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.43 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © HeWhoMustNotBeNamed
  3.  
  4. // __ __ __ __ __ __ __ __ __ __ __ _______ __ __ __
  5. // / | / | / | _ / |/ | / \ / | / | / \ / | / | / \ / \ / | / |
  6. // $$ | $$ | ______ $$ | / \ $$ |$$ |____ ______ $$ \ /$$ | __ __ _______ _$$ |_ $$ \ $$ | ______ _$$ |_ $$$$$$$ | ______ $$ \ $$ | ______ _____ ____ ______ ____$$ |
  7. // $$ |__$$ | / \ $$ |/$ \$$ |$$ \ / \ $$$ \ /$$$ |/ | / | / |/ $$ | $$$ \$$ | / \ / $$ | $$ |__$$ | / \ $$$ \$$ | / \ / \/ \ / \ / $$ |
  8. // $$ $$ |/$$$$$$ |$$ /$$$ $$ |$$$$$$$ |/$$$$$$ |$$$$ /$$$$ |$$ | $$ |/$$$$$$$/ $$$$$$/ $$$$ $$ |/$$$$$$ |$$$$$$/ $$ $$< /$$$$$$ |$$$$ $$ | $$$$$$ |$$$$$$ $$$$ |/$$$$$$ |/$$$$$$$ |
  9. // $$$$$$$$ |$$ $$ |$$ $$/$$ $$ |$$ | $$ |$$ | $$ |$$ $$ $$/$$ |$$ | $$ |$$ \ $$ | __ $$ $$ $$ |$$ | $$ | $$ | __ $$$$$$$ |$$ $$ |$$ $$ $$ | / $$ |$$ | $$ | $$ |$$ $$ |$$ | $$ |
  10. // $$ | $$ |$$$$$$$$/ $$$$/ $$$$ |$$ | $$ |$$ \__$$ |$$ |$$$/ $$ |$$ \__$$ | $$$$$$ | $$ |/ |$$ |$$$$ |$$ \__$$ | $$ |/ |$$ |__$$ |$$$$$$$$/ $$ |$$$$ |/$$$$$$$ |$$ | $$ | $$ |$$$$$$$$/ $$ \__$$ |
  11. // $$ | $$ |$$ |$$$/ $$$ |$$ | $$ |$$ $$/ $$ | $/ $$ |$$ $$/ / $$/ $$ $$/ $$ | $$$ |$$ $$/ $$ $$/ $$ $$/ $$ |$$ | $$$ |$$ $$ |$$ | $$ | $$ |$$ |$$ $$ |
  12. // $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$/ $$$$$$/ $$/ $$/ $$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$$$$$/ $$$$/ $$$$$$$/ $$$$$$$/ $$/ $$/ $$$$$$$/ $$/ $$/ $$/ $$$$$$$/ $$$$$$$/
  13. //
  14. //
  15. //
  16. //@version=5
  17. indicator("Run Timer", overlay=true)
  18. key = input.string("", title="Key", group="Auth")
  19. trialBars = input.int(5, title="Trial Period (In Bars)", group="Auth")
  20. f_getTimer()=>
  21. var timestart = timenow
  22. barcount = ta.barssince(barstate.islastconfirmedhistory)
  23. mseconds = timenow-timestart
  24. seconds = mseconds/1000
  25. minutes = seconds/60
  26. hours = minutes/60
  27. days = hours/24
  28.  
  29. tmSeconds = mseconds%1000
  30. tSeconds = seconds%60
  31. tMinutes = minutes%60
  32. tHours = hours%60
  33. [days, tHours, tMinutes, tSeconds, tmSeconds, barcount]
  34.  
  35. [days, tHours, tMinutes, tSeconds, tmSeconds, barcount] = f_getTimer()
  36. validKey = (key == "1234" or nz(barcount,0) <= trialBars)
  37.  
  38. var timer = table.new(position=position.top_center, columns=10, rows=1, border_width=0)
  39. backgroundColor = validKey? color.green : color.red
  40. table.cell(table_id=timer, column=0, row=0, text=str.tostring(days, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
  41. table.cell(table_id=timer, column=1, row=0, text="/", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
  42. table.cell(table_id=timer, column=2, row=0, text=str.tostring(tHours, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
  43. table.cell(table_id=timer, column=3, row=0, text=":", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
  44. table.cell(table_id=timer, column=4, row=0, text=str.tostring(tMinutes, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
  45. table.cell(table_id=timer, column=5, row=0, text=":", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
  46. table.cell(table_id=timer, column=6, row=0, text=str.tostring(tSeconds, "00"), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
  47. table.cell(table_id=timer, column=7, row=0, text=".", bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
  48. table.cell(table_id=timer, column=8, row=0, text=str.tostring(tmSeconds), bgcolor=backgroundColor, text_color=color.white, text_size=size.normal)
Advertisement
Add Comment
Please, Sign In to add comment