Time Functions
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © standingtiger

//@version=5

// @description TODO: add library description here
library("TimeFunctions")

// @function TODO: add function description here
// @param x TODO: add parameter x description here
// @returns TODO: add what function returns
//export fun(float x) =>
	//TODO : add function body and return value here
//	x

export TimeframetoInt(string tf) =>
    int i = switch tf
        "1" => 1
        "5" => 5
        "10" => 10
        "15" => 15
        "30" => 30
        "60" => 60
        "H1" => 60
        "H4" => 240
        "1D" => 1440

export BarsSinceOpen(int t, string timeframe) =>
    t1 = (((t%8.64e7)/1000)-48600)/60
    tf = TimeframetoInt(timeframe)
    t2 = t1/tf
    t2

