FFriZz

FrizLabz_Time_Utility_Methods

FFriZz ที่อัปเดต:   
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 .
  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 this will return the
time of the bar = to the bar that corresponds to 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

GET(box)
  Gets the location paramaters of a Box
  Parameters:
    box: (box)
  Returns: tuple

GET(label)
  Gets the location paramaters and text of a Label
  Parameters:
    label: (label)
  Returns: tuple

GET(linefill)
  Gets line 1 and 2 from a Linefill
  Parameters:
    linefill: (linefill)
  Returns: tuple

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

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
เอกสารเผยแพร่:
Library "FrizLabz_Time_Utility_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 .
  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 this will return the
time of the bar = to the bar that corresponds to 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)
  Parameters:
    time_or_index
    timezone
    format

GET(line)
  Gets the location paramaters of a Box
  Parameters:
    line
  Returns: tuple

GET(box)
  Gets the location paramaters and text of a Label
  Parameters:
    box
  Returns: tuple

GET(label)
  Gets line 1 and 2 from a Linefill
  Parameters:
    label
  Returns: tuple

GET(linefill)
  Parameters:
    linefill

Format(line, timezone)
  Parameters:
    line
    timezone

Line(x1, y1, x2, y2, extend, color, style, width)
  Parameters:
    x1
    y1
    x2
    y2
    extend
    color
    style
    width

Box(left, top, right, bottom, extend, border_color, bgcolor, text_color, border_width, border_style, txt, text_halign, text_valign, text_size, text_wrap)
  Parameters:
    left
    top
    right
    bottom
    extend
    border_color
    bgcolor
    text_color
    border_width
    border_style
    txt
    text_halign
    text_valign
    text_size
    text_wrap

Label(x, y, txt, yloc, color, textcolor, style, size, textalign, text_font_family, tooltip)
  Parameters:
    x
    y
    txt
    yloc
    color
    textcolor
    style
    size
    textalign
    text_font_family
    tooltip
เอกสารเผยแพร่:
v3

Updated:
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 .
  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 this will return the
time of the bar = to the bar that corresponds to 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(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 horizontal 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 object

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 object

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
เอกสารเผยแพร่:
v4 bug fixes
เอกสารเผยแพร่:
v5
Changed: index_time() to index_to_time() so that index_to_time() and time_to_index() closer match in names

Removed: GET(), Format(), Line(), Label(), Box()
I'll be releasing a library that has functions that mirror these
เอกสารเผยแพร่:
v6
Fixed display

ไลบรารีไพน์

จิตวิญญาณที่แท้จริงของ TradingView ผู้เขียนได้ตีพิมพ์รหัส Pine นี้เป็นไลบรารีโอเพนซอร์ซเพื่อให้โปรแกรมเมอร์คนอื่น ๆ จากชุมชนของเราสามารถนำไปใช้ซ้ำได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ไลบรารีนี้เป็นการส่วนตัวหรือในสิ่งพิมพ์โอเพนซอร์สอื่น ๆ แต่นำรหัสนี้มาใช้ซ้ำในสิ่งพิมพ์จะถูกควบคุมโดย กฎของบ้าน

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการใช้ไลบรารีนี้หรือไม่?

คัดลอกข้อความไปยังคลิปบอร์ดแล้ววางลงในสคริปต์ของคุณ