PINE LIBRARY

BarTimeLibrary

Обновлено
Library "BarTimeLibrary"
TODO: add library description here

atr_anysource(source, atr_length)
  Parameters:
    source (float)
    atr_length (simple int)

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): (int) +/- utc offset
  Returns: string string to be added to the timezone paramater for utc timezone usage

method bar_time(bar_amount)
  from a time to index
  Namespace types: series int, simple int, input int, const int
  Parameters:
    bar_amount (int): (int) default - 1)
  Returns: int bar_time

method time_to_index(_time)
  from time to bar_index
  Namespace types: series int, simple int, input int, const int
  Parameters:
    _time (int): (int)
  Returns: int time_to_index bar_index that corresponds to time provided

method time_to_bars_back(_time)
  from a time quanity to bar quanity for use with [historical ref].
  Namespace types: series int, simple int, input int, const int
  Parameters:
    _time (int): (int)
  Returns: int bars_back yeilds the amount of bars from current bar to reach _time provided

method bars_back_to_time(bars_back)
  from bars_back to time
  Namespace types: series int, simple int, input int, const int
  Parameters:
    bars_back (int)
  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

method index_time(index)
  bar_index to UNIX time
  Namespace types: series int, simple int, input int, const int
  Parameters:
    index (int): (int)
  Returns: int time time in unix that corrresponds to the bar_index

method 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
  Namespace types: series int, simple int, input int, const int
  Parameters:
    time_or_index (int): (int) required) time in unix or bar_index
    timezone (int): (int) required) utc offset to be appled to output
    format (string): (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

method GET(line)
  Gets the location paramaters of a Line
  Namespace types: series line
  Parameters:
    line (line): (line)
  Returns: tuple int x1,float y1,int x2,float y2

method GET(box)
  Gets the location paramaters of a Box
  Namespace types: series box
  Parameters:
    box (box): (box)
  Returns: tuple int left,float top,int right,float bottom

method GET(label)
  Gets the location paramaters and text of a Label
  Namespace types: series label
  Parameters:
    label (label): (label)
  Returns: tuple int x,float y,string _text

method GET(linefill)
  Gets line 1 and 2 from a Linefill
  Namespace types: series linefill
  Parameters:
    linefill (linefill): (linefill)
  Returns: tuple line line1,line line2

method 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
  Namespace types: series line
  Parameters:
    line (line): (line) required
    timezone (int): (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): (int) default - time
    y1 (float): (float) default - close
    x2 (int): (int) default - last_bar_time/last_bar_index not required for line that ends on current bar
    y2 (float): (float) default - y1 not required for flat line
    extend (string): (string) default - extend.none extend.left, extend.right, extend.both
    color (color): (color) default - chart.fg_color
    style (string): (string) default - line.style_solid line.style_dotted, line.style_dashed,
line.style_arrow_both, line.style_arrow_left, line.style_arrow_right
    width (int)
  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): (int) default - time
    top (float): (float) required
    right (int): (int) default - last_bar_time/last_bar_index will default to current bar index or time depending on (left) arg
    bottom (float): (float) required
    extend (string): (string) default - extend.none extend.left, extend.right, extend.both
    border_color (color): (color) default - chart.fg_color
    bgcolor (color): (color) default - color.new(chart.fg_color,75)
    text_color (color): (color) default - chart.bg_color
    border_width (int): (int) default - 1
    border_style (string): (string) default - line.style_solid line.style_dotted, line.style_dashed,
    txt (string): (string) default - ''
    text_halign (string): (string) default - text.align_center text.align_left, text.align_right
    text_valign (string): (string) default - text.align_center text.align_top, text.align_bottom
    text_size (string): (string) default - size.normal size.tiny, size.small, size.large, size.huge
    text_wrap (string): (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): (int) default - time
    y (float): (float) default - high or low depending on bar direction
    txt (string): (string) default - ''
    yloc (string): (string) default - yloc.price yloc.price, yloc.abovebar, yloc.belowbar
    color (color): (color) default - chart.fg_color
    textcolor (color): (color) default - chart.bg_color
    style (string): (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): (string) default - size.normal size.tiny, size.small, size.large, size.huge
    textalign (string): (string) default - text.align_center text.align_left, text.align_right
    text_font_family (string): (string) default - font.family_default font.family_monospace
    tooltip (string): (string) default - na
  Returns: label

f_simpleLowHigh()
  _simpleLowHigh() // This function finds Local Lows and Highs, but NOT in order. A Local High is any candle that has its Low taken out on close by a subsequent candle (and vice-versa for Local Lows).
The Local High does NOT have to be the candle with the highest High out of recent candles. It does NOT have to be a Williams High. It is not necessarily a swing high or a reversal or anything else.
It doesn't have to be "the" high, so don't be confused.
By the rules, Local Lows and Highs must alternate. In this function they do not, so I'm calling them Simple Lows and Highs.
Simple Highs and Lows, by the above definition, can be useful for entries and stops. Because I intend to use them for stops, I want them all, not just the ones that alternate in strict order.
  Returns: boolean values for whether this bar confirms a Simple Low/High, and ints for the bar_index of that Low/High.

f_localLowHigh()
  f_localLowHigh() // This function finds Local Lows and Highs, in order. A Local High is any candle that has its Low taken out on close by a subsequent candle (and vice-versa for Local Lows).
The Local High does NOT have to be the candle with the highest High out of recent candles. It does NOT have to be a Williams High. It is not necessarily a swing high or a reversal or anything else.
By the rules, Local Lows and Highs must alternate, and in this function they do.
  Returns: boolean values for whether this bar confirms a Local Low/High, and ints for the bar_index of that Low/High.

f_enhancedSimpleLowHigh()
  f_enhancedSimpleLowHigh() // This function finds Local Lows and Highs, but NOT in order. A Local High is any candle that has its Low taken out on close by a subsequent candle (and vice-versa for Local Lows).
The Local High does NOT have to be the candle with the highest High out of recent candles. It does NOT have to be a Williams High. It is not necessarily a swing high or a reversal or anything else.
By the rules, Local Lows and Highs must alternate. In this function they do not, so I'm calling them Simple Lows and Highs.
Simple Highs and Lows, by the above definition, can be useful for entries and stops. Because I intend to use them for trailing stops, I want them all, not just the ones that alternate in strict order.
The difference between this function and f_simpleLowHigh() is that it also tracks the lowest/highest recent level. This level can be useful for trailing stops.
In effect, these are like more "normal" highs and lows that you would pick by eye, but confirmed faster in many cases than by waiting for the low/high of that particular candle to be taken out on close,
because they are instead confirmed by ANY subsequent candle having its low/high exceeded. Hence, I call these Enhanced Simple Lows/Highs.
The levels are taken from the extreme highs/lows, but the bar indexes are given for the candles that were actually used to confirm the Low/High.
This is by design, because it might be misleading to label the extreme, since we didn't use that candle to confirm the Low/High..
  Returns: - boolean values for whether this bar confirms an Enhanced Simple Low/High
ints for the bar_index of that Low/High
floats for the values of the recent high/low levels
floats for the trailing high/low levels (for debug/post-processing)
bools for market structure bias

f_trueLowHigh()
  f_trueLowHigh() // This function finds True Lows and Highs.
A True High is the candle with the highest recent high, which then has its low taken out on close by a subsequent candle (and vice-versa for True Lows).
The difference between this and an Enhanced High is that confirmation requires not just any Simple High, but confirmation of the very candle that has the highest high.
Because of this, confirmation is often later, and multiple Simple Highs and Lows can develop within ranges formed by a single big candle without any of them being confirmed. This is by design.
A True High looks like the intuitive "real high" when you look at the chart. True Lows and Highs must alternate.
  Returns: - boolean values for whether this bar confirms an Enhanced Simple Low/High
ints for the bar_index of that Low/High
floats for the values of the recent high/low levels
floats for the trailing high/low levels (for debug/post-processing)
bools for market structure bias

method RoundToHundreds(value)
  Namespace types: series float, simple float, input float, const float
  Parameters:
    value (float)

method get_Projected_BW(h, l, length)
  Namespace types: series float, simple float, input float, const float
  Parameters:
    h (float)
    l (float)
    length (int)

method f_step(x)
  Namespace types: series float, simple float, input float, const float
  Parameters:
    x (float)

method f_rounding(_value, _step, _option)
  Namespace types: series float, simple float, input float, const float
  Parameters:
    _value (float)
    _step (float)
    _option (string)

Get_HT()

Get_PreviousDayLevels()

kernel_regression_low(_h, _l, _o, _c)
  Parameters:
    _h (float)
    _l (float)
    _o (float)
    _c (float)

rngfilt(rangeLimit, _h, _l, _o, _c)
  Parameters:
    rangeLimit (float)
    _h (float)
    _l (float)
    _o (float)
    _c (float)
  Returns: rngfilt (series) required

function_getShapeShiftMA(length, smooth, pow, src)
  Parameters:
    length (int)
    smooth (bool)
    pow (float)
    src (float)

function_getFilter(length, candle, src)
  Parameters:
    length (int)
    candle (bool)
    src (float)

hi(val)
  Parameters:
    val (float)

draw(o, h, l, c, oBar, cBar, ccolor, trendline, barToConsiderForTL)
  draws candles based on ohlc values
  Parameters:
    o (float): Open Price
    h (float): High Price
    l (float): Low Price
    c (float): Close Price
    oBar (int): Open Time
    cBar (int): Close Time
    ccolor (color)
    trendline (bool)
    barToConsiderForTL (int)
  Returns: void
reverted Version 60

getLadderStepIncrement(_price)
  Parameters:
    _price (float)

getLadderIndexForPrice(_price, _ladderRange)
  Parameters:
    _price (float)
    _ladderRange (float)

getLadderStartPriceRange(_price, _ladderRange)
  Parameters:
    _price (float)
    _ladderRange (float)
Информация о релизе
v2
arraysbar_types

Библиотека Pine

В истинном духе TradingView автор опубликовал этот код Pine как библиотеку с открытым исходным кодом, чтобы другие программисты Pine из нашего сообщества могли им воспользоваться. Вы можете использовать эту библиотеку в приватных или других публикациях с открытым исходным кодом, но повторное использование этого кода в публикации регулируется Правилами поведения.


Мои профили:

Отказ от ответственности