Library "FrizLabz_Time_Utility_Methods"
Some time to index and index to time helper methods made them for another library thought I would try to make
them as methods
UTC_helper(utc)
UTC helper function this adds the + to the positive utc times, add "UTC" to the string
and can be used in the timezone arg of for format_time()
Parameters:
utc: (int) | +/- utc offset
Returns: string | string to be added to the timezone paramater for utc timezone usage
bar_time(bar_amount)
from a time to index
Parameters:
bar_amount: (int) | default - 1)
Returns: int bar_time
time_to_index(_time)
from time to bar_index
Parameters:
_time: (int)
Returns: int time_to_index | bar_index that corresponds to time provided
time_to_bars_back(_time)
from a time quanity to bar quanity for use with [historical ref].
Parameters:
_time: (int)
Returns: int bars_back | yeilds the amount of bars from current bar to reach _time provided
bars_back_to_time(bars_back)
from bars_back to time
Parameters:
bars_back
Returns: int | using same logic as [historical ref.] this will return the
time of the bar = to the bar that corresponds to [x] bars_back
index_time(index)
bar_index to UNIX time
Parameters:
index: (int)
Returns: int time | time in unix that corrresponds to the bar_index
to_utc(time_or_index, timezone, format)
method to use with a time or bar_index variable that will detect if it is an index or unix time
and convert it to a printable string
Parameters:
time_or_index: (int) required) | time in unix or bar_index
timezone: (int) required) | utc offset to be appled to output
format: (string) | default - "yyyy-MM-dd'T'HH:mm:ssZ") | the format for the time, provided string is
default one from str.format_time()
Returns: string | time formatted string
GET(line)
Gets the location paramaters of a Line
Parameters:
line: (line)
Returns: tuple [int x1,float y1,int x2,float y2]
GET(box)
Gets the location paramaters of a Box
Parameters:
box: (box)
Returns: tuple [int left,float top,int right,float bottom]
GET(label)
Gets the location paramaters and text of a Label
Parameters:
label: (label)
Returns: tuple [int x,float y,string _text]
GET(linefill)
Gets line 1 and 2 from a Linefill
Parameters:
linefill: (linefill)
Returns: tuple [line line1,line line2]
Format(line, timezone)
converts Unix time in time or index params to formatted time
and returns a tuple of the params as string with the time/index params formatted
Parameters:
line: (line) | required
timezone: (int) | default - na
Returns: tuple [string x1,string y1,string x2,string y2]
Line(x1, y1, x2, y2, extend, color, style, width)
similar to line.new() with the exception
of not needing to include y2 for a flat line, y1 defaults to close,
and it doesnt require xloc.bar_time or xloc.bar_index, if no x1
Parameters:
x1: (int) default - time
y1: (float) default - close
x2: (int) default - last_bar_time/last_bar_index | not required for line that ends on current bar
y2: (float) default - y1 | not required for flat line
extend: (string) default - extend.none | extend.left, extend.right, extend.both
color: (color) default - chart.fg_color
style: (string) default - line.style_solid | line.style_dotted, line.style_dashed,
line.style_arrow_both, line.style_arrow_left, line.style_arrow_right
width
Returns: line
Box(left, top, right, bottom, extend, border_color, bgcolor, text_color, border_width, border_style, txt, text_halign, text_valign, text_size, text_wrap)
similar to box.new() but only requires top and bottom to create box,
auto detects if it is bar_index or time used in the (left) arg. xloc.bar_time and xloc.bar_index are not used
args are ordered by purpose | position -> colors -> styling -> text options
Parameters:
left: (int) default - time
top: (float) required
right: (int) default - last_bar_time/last_bar_index | will default to current bar index or time
depending on (left) arg
bottom: (float) required
extend: (string) default - extend.none | extend.left, extend.right, extend.both
border_color: (color) default - chart.fg_color
bgcolor: (color) default - color.new(chart.fg_color,75)
text_color: (color) default - chart.bg_color
border_width: (int) default - 1
border_style: (string) default - line.style_solid | line.style_dotted, line.style_dashed,
txt: (string) default - ''
text_halign: (string) default - text.align_center | text.align_left, text.align_right
text_valign: (string) default - text.align_center | text.align_top, text.align_bottom
text_size: (string) default - size.normal | size.tiny, size.small, size.large, size.huge
text_wrap: (string) default - text.wrap_auto | text.wrap_none
Returns: box
Label(x, y, txt, yloc, color, textcolor, style, size, textalign, text_font_family, tooltip)
similar to label.new() but only requires no args to create label,
auto detects if it is bar_index or time used in the (x) arg. xloc.bar_time and xloc.bar_index are not used
args are ordered by purpose | position -> colors -> styling -> text options
Parameters:
x: (int) default - time
y: (float) default - high or low | depending on bar direction
txt: (string) default - ''
yloc: (string) default - yloc.price | yloc.price, yloc.abovebar, yloc.belowbar
color: (color) default - chart.fg_color
textcolor: (color) default - chart.bg_color
style: (string) default - label.style_label_down | label.style_none
label.style_xcross,label.style_cross,label.style_triangleup,label.style_triangledown
label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown,
label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right,
label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left,
label.style_label_upper_right, label.style_label_center, label.style_square,
label.style_diamond
size: (string) default - size.normal | size.tiny, size.small, size.large, size.huge
textalign: (string) default - text.align_center | text.align_left, text.align_right
text_font_family: (string) default - font.family_default | font.family_monospace
tooltip: (string) default - na
Returns: label