PINE LIBRARY

FrizBug

Atualizado
Library "FrizBug"
Debug Tools | Pinescript Debugging Tool Kit

All in one Debugger - the benefit of wrapper functions to simply wrap variables or outputs and have the code still execute the same. Perfect for Debugging on Pine

str(inp)
  Overloaded tostring like Function for all type+including Object Variables [ie. x1,y1,x2,y2] will also do arrays and matricies of all Types
  Parameters:
    inp: All types
  Returns: string

print_label(str, x_offset, y, barstate, style, color, textcolor, text_align, size)
  Label Helper Function - only needs the Str input to work
  Parameters:
str:
    x_offset: offset from last bar + or -
    y: price of label
    barstate: barstate built in variable [barstate.islast]
    style: label style settin7[label.style_label_upper_left]
    color: color setting [color.black]
    textcolor: textcolor [color.lime]
    text_align: text align setting [text.align_right/left/center]
    size: text_sise ['tiny','normal', or text.large, text.auto]
  Returns: label

init()
  initializes the database arrays [1 var <string> and 1 varip <string>]
  Returns: tuple [log,live] | 2 matrix<string> (1 matrix is varip(live) the other is reagular var (Bar))

update(log, live, live_console, log_console, live_lbl, log_lbl)
  Put at the very end of your code / This updates all of the consoles
  Parameters:
    log: This matrix is the one used for Bar updates
    live: This matrix is the one used for Real Time updates
    live_console: on_offs for the consoles and lbls - call in the update function
    log_console: on_offs for the consoles and lbls - call in the update function
    live_lbl: on_offs for the consoles and lbls - call in the update function
    log_lbl: on_offs for the consoles and lbls - call in the update function
  Returns: void

log(log, inp, str_label, off, rows, index_cols, bars_back)
  Function Will push to the Console offset to the right of Current bar, This is the main Console - it has 2 Feeds left and right (changeable)"
  Parameters:
    log: Matrix - Log or Live
    inp: All types
    str_label: (optional) This input will label it on the feed
    off: Useful for when you don't want to remove the function"
    rows: when printing or logging a matrix this will shorten the output will show last # of rows"
    index_cols: When printing or logging a array or matrix this will shorten the array or the columns of a matrix by the #"
    bars_back: Adjustment for Bars Back - Default is 1 (0 for barstate.islast)"
  Returns: inp - all types (The log and print functions can be used as wrapper functions see usage below for examples)

Print(log, str_label, off, bars_back)
  Function can be used to send information to a label style Console, Can be used as a wrapper function, Similar to str.format use with str()
  Parameters:
    log:
    str_label: (optional) Can be used to label Data sent to the Console
    off: Useful for when you don't want to remove the function
    bars_back: Adjustment for Bars Back - Default is 1 (0 for barstate.islast)
  Returns: string

print(inp, str_label, off, bars_back)
  This Function can be used to send information to a label style Console, Can be used as a wrapper function, Overload print function
  Parameters:
    inp: All types
    str_label: string (optional) Can be used to label Data sent to the Console
    off: Useful for when you don't want to remove the function
    bars_back: Adjustment for Bars Back - Default is 1 (0 for barstate.islast)
  Returns: inp - all types (The log and print functions can be used as wrapper functions see usage below for examples)

Credits:
kaigouthro - for the font library
RicardoSantos - for the concept I used to make this
Thanks!

Use cases at the bottom
Notas de Lançamento
v2

Added:
console()

Updated:

init()
  initializes the database arrays [1 var <string> and 1 varip <string>]
  Returns: [console,tick] - tuple 2 matrix<string> 1 matrix is varip(tick) the other is reagular var (Bar)

update(memory, tick, live_console, console_console, live_lbl, console_lbl)
  Put at the very end of your code / This updates all of the consoles
  Parameters:
    memory: This matrix is the one used for Bar updates
    tick: This matrix is the one used for Real Time updates
    live_console: on_offs for the consoles and lbls - call in the update function
    console_console: on_offs for the consoles and lbls - call in the update function
    live_lbl: on_offs for the consoles and lbls - call in the update function
    console_lbl: on_offs for the consoles and lbls - call in the update function
  Returns: void

log()

print()

Removed:
Print(log, str_label, off, bars_back)
  Function can be used to send information to a label style Console, Can be used as a wrapper function, Similar to str.format use with str()

Little update will update this page when i have some time
Notas de Lançamento
v5

Updated:
console()

print()

Got print function working tick and bar updates more info in chart pic
Notas de Lançamento
=) v6
Notas de Lançamento
v7

Updated:
str(input)
  Parameters:
    input

print_label(str, x_offset, y, barstate, style, color, textcolor, text_align, size)
  print_label
  Parameters:
    str: string - the string to be displayed in the label
    x_offset: int - offset from last bar in time units, default is 150
    y: float - the price at which the label will be displayed, default is the high of the current bar
    barstate: bool - whether the label should be displayed on the last bar, default is true
    style: string - the style of the label, default is label.style_label_lower_right
    color: color - the color of the label, default is black
    textcolor: color - the color of the text in the label, default is lime green
    text_align: string - the alignment of the text in the label, default is text.align_left
    size: string - the size of the text in the label, default is 'normal'
  Returns: label - the created label object
description
This function creates and returns a label object that can be displayed on the chart.
The label displays the given string at the specified price, with the specified styling and colors.
The label is displayed on the last bar by default, but this can be changed by setting the barstate parameter.
The x_offset parameter determines the offset from the last bar in time units.

init(UTC, console, type)
  init
  Parameters:
    UTC: integer - representing the time zone offset from UTC in hours. A positive value means the time zone is ahead of UTC (e.g. UTC+3),
while a negative value means the time zone is behind UTC (e.g. UTC-5). The default value is -6.
    console: string - indicating the type of console to output data to. Valid options are 'table', 'label', 'box', and 'tool'.
The default value is 'table'.
    type: string - indicating the type of data to output. Valid options are 'tick' and 'bar'. The default value is 'bar'.
return out string[] - string array for logging debug data.
description
This function initializes the output data for a script by creating an array of strings called out,
and sets its value based on the values of the console and type parameters.
It also sets the utc variable to a string representation of the UTC parameter, and adds a header string to the beginning of out
indicating the type of console being used and the data type being output.
The possible values for console are 'table', 'label', 'box', and 'tool',
and the possible values for type are 'tick' and 'bar'.
The default values for console and type are 'table' and 'bar' respectively.
The function returns out (string[]) at the end.

update(console1, console2, console3)
  update
  Parameters:
    console1: string[] - An array of strings representing the console to be updated.
    console2: string[] - An array of strings representing the console to be updated.
    console3: string[] - An array of strings representing the console to be updated.
return (void)
description
The update function updates the given consoles with the latest input in their respective buffers.
It also checks for the type of console and updates the label, table, box, or tooltip accordingly.
If a console is not provided or is empty, it is skipped.

print(input, data_label, tick, pos, off, m_rows, a_index_m_cols, size, text_size, bg_color, text_color, border_color, UTC)
  print
  Parameters:
    input: type - The input to be printed in the console
of the console on the chart. Valid values are "1-9",
    off: bool - A flag indicating whether to disable printing [true] or enable it [false]. Default value is false.
    m_rows: int - An optional parameter for printing a matrix with a specified number of rows.
    a_index_m_cols: int - An optional parameter for printing a matrix with a specified number of columns.
    size: int - The maximum number of lines that can be displayed in the console. Default value is 20.
    text_size: string - The size of the text in the console. Default value is `size.small`.
    bg_color: color - The background color of the console. Default value is `#00000075`.
    text_color: color - The color of the text in the console. Default value is `#00ff00`.
    border_color: color - The color of the border around the console. Default value is `#00ff00`.
    UTC: int - The time zone offset to use when displaying timestamps in the console. Default value is -6.

Removed:
console_colors

-- Finally had some time to update the function headers hope this helps
Notas de Lançamento
v8

Updated:
init(UTC, console, type)
  init
  Parameters:
    UTC: integer - representing the time zone offset from UTC in hours. A positive value means the time zone is ahead of UTC (e.g. UTC+3),
while a negative value means the time zone is behind UTC (e.g. UTC-5). The default value is -6.
    console: string - indicating the type of console to output data to. Valid options are 'table', 'label', 'box', and 'tool'.
The default value is 'table'.
    type: string - indicating the type of data to output. Valid options are 'tick' and 'bar'. The default value is 'bar'.
  Returns: out string[] - string array for logging debug data.
description
This function initializes the output data for a script by creating an array of strings called out,
and sets its value based on the values of the console and type parameters.
It also sets the utc variable to a string representation of the UTC parameter, and adds a header string to the beginning of out
indicating the type of console being used and the data type being output.
The possible values for console are 'table', 'label', 'box', and 'tool',
and the possible values for type are 'tick' and 'bar'.
The default values for console and type are 'table' and 'bar' respectively.
The function returns out (string[]) at the end.

update(console1, console2, console3)
  update
  Parameters:
    console1: string[] - An array of strings representing the console to be updated.
    console2: string[] - An array of strings representing the console to be updated.
    console3: string[] - An array of strings representing the console to be updated.
  Returns: (void)
description
The update function updates the given consoles with the latest input in their respective buffers.
It also checks for the type of console and updates the label, table, box, or tooltip accordingly.
If a console is not provided or is empty, it is skipped.

Removed:
console(input, tick, position, size, text_size, bg_color, text_color, border_color, UTC, data_label)
  console

did a couple little updates added some documentation at the top of the script
Notas de Lançamento
v9

added a safety check in the print() helper function to shorten string if it reaches a length of > 4000 before it gets added to the array and then does its final string check
Notas de Lançamento
v10

Updated:
init(UTC, console)
  Parameters:
    UTC
    console

update(console1, console2, console3, bg_color, text_color, border_color)
  - The update function updates the given consoles with the latest input in their respective buffers.
It also checks for the type of console and updates the label, table, box, or tooltip accordingly.
If a console is not provided or is empty, it is skipped.
  Parameters:
    console1: string[] - An array of strings representing the console to be updated.
    console2: string[] - An array of strings representing the console to be updated.
    console3: string[] - An array of strings representing the console to be updated.
    bg_color: color - Color of the bg of the consoles
    text_color: color - Color of the text of the consoles
    border_color
  Returns: (void)

log(console, inp, data_label, off, loop, tick, m_rows, m_cols)
  Parameters:
    console
    inp
    data_label
    off
    loop
    tick
    m_rows
    m_cols

print(input, data_label, tick, pos, off, loop, UTC, m_rows, m_cols, size, text_size, bg_color, text_color)
  Parameters:
    input
    data_label
    tick
    pos
    off
    loop
    UTC
    m_rows
    m_cols
    size
    text_size
    bg_color
    text_color

Removed:
print_label(str, x_offset, y, barstate, style, color, textcolor, text_align, size)
  print_label
Notas de Lançamento
v11 comment out usage code for speed for the user
Notas de Lançamento
v12

Added:
shorten(str, a_index, m_rows, m_cols)
  ● This function is designed to shorten the string representation of either a matrix or an array by limiting the number of rows and columns displayed.
If the input str is a matrix or array, the function first sets the variables mtx and arr to true or false depending on the value of the a_or_m input.
If mtx is true and the current bar is the last bar of the bar series and either m_rows or a_index_m_cols are not zero,
the function performs the following steps:
● It removes all square brackets, newline characters, and empty brackets from the input string and splits it into an array s_s at the brackets.
● It splits the first element of s_s into an array s_ss at the comma and space.
● If the size of s_s is greater than m_rows * 2 or the size of s_ss is greater than a_index_m_cols * 2,
the function performs the following steps:
● It creates a new array m_strbot and sets a variable pop_shift to the integer value of m_rows.
● It creates a copy c_ of s_s and iterates over it in reverse, popping elements from c_ and appending them to m_strbot.
● For each element, it splits it into an array s_s_s at the comma and space.
If the size of s_s_s is less than or equal to a_index_m_cols * 2,
it simply appends the element to m_strbot.
If the size of s_s_s is greater than a_index_m_cols * 2,
it creates a new array a_strbot, sets a variable a_pop_shift to the integer value of a_index_m_cols,
and performs the following steps:
● It iterates over s_s_s in reverse, popping elements from it and appending them to a_strbot.
● It creates a new array a_strtop and iterates over s_s_s in forward order,
shifting elements from it and appending them to a_strtop.
● It concatenates a_strtop and a_strbot and joins them with a comma and space,
then appends the resulting string to m_strbot as an element.
● It creates a new array m_strtop and sets c_ to a copy of s_s.
It iterates over c_ in forward order,
shifting elements from it and appending them to m_strtop.
For each element, it splits it into an array s_s_s at the comma and space.
If the size of s_s_s is less than or equal to a_index_m_cols * 2,
it simply appends the element to m_strtop.
If the size of s_s_s is greater than a_index_m_cols * 2,
it performs the same steps as before to create a_strtop and a_strbot, concatenates them,
and appends the resulting string to `m_strtop It concatenates m_strbot and m_strtop and joins them
with a comma and space to create a new string m_out.
It then sets out to m_out, preceded by '\n'.
● If arr and barstate.islast and (m_rows or a_index_m_cols) is true,
it performs similar steps to shorten the input string if it is an array.
● It creates a new array s_s by splitting str at the square brackets and creates
a new array s_ss by splitting the first element of s_s at the comma and space.
● If the size of s_s is greater than m_rows * 2 or the size of s_ss is greater than a_index_m_cols * 2,
it creates new arrays a_strbot and a_strtop as before and concatenates them to create a new string a_out.
It then sets out to a_out, preceded by '\n'.
● Finally, the function returns out[shortened array/matrix].
  Parameters:
    str: string - The input string to be shortened.
    a_index: int - The number of indexs to keep in array when shortening it. Default value is 0.
    m_rows: int - The number of rows to keep in the matrix when shortening it. Default value is 0.
    m_cols: int - The number of columns matrix when shortening it. Default value is 0.
  Returns: string - The shortened string.
Description:

converted to methods
Notas de Lançamento
Library "FrizBug"
: Debug Tools | The Pinescript Debugging Tool Kit

added docs() acts as a hover over reference for the documentation

docs()
init(console)
  init() - Console init Function**

  Parameters:
    input: - ('any type') required
  Returns: `string` of the input

str(input)
  Parameters:
    input


update(console1, console2, console3, bg_color, text_color, border_color)
  Parameters:
    console1
    console2
    console3
    bg_color
    text_color
    border_color

shorten(str, a_index, m_rows, m_cols)
  Parameters:
    str
    a_index
    m_rows
    m_cols


log(console, inp, data_label, off, loop, tick, m_rows, m_cols)
  Parameters:
    console
    inp
    data_label
    off
    loop
    tick
    m_rows
    m_cols


print(input, data_label, tick, pos, off, loop, m_rows, m_cols, size, text_size, bg_color, text_color)
  Parameters:
    input
    data_label
    tick
    pos
    off
    loop
    m_rows
    m_cols
    size
    text_size
    bg_color
    text_color

any
  Fields:
    any
Notas de Lançamento
v14

Updated:
docs()
Hover over documentation
need to clean this code up still works fine for now but I can implement objects once I have time
  
Notas de Lançamento
v15

Updated:
method log(inp, console, data_label, off, buffer, loop, tick, m_rows, m_cols)
  Namespace types: matrix<linefill>
  Parameters:
    inp (matrix<linefill>)
    console (string[])
    data_label (string)
    off (bool)
    buffer (int)
    loop (int)
    tick (bool)
    m_rows (int)
    m_cols (int)

method print(input, data_label, tick, pos, buffer, off, loop, m_rows, m_cols, size, text_size, bg_color, text_color)
  Namespace types: matrix<linefill>
  Parameters:
    input (matrix<linefill>)
    data_label (string)
    tick (bool)
    pos (string)
    buffer (int)
    off (bool)
    loop (int)
    m_rows (int)
    m_cols (int)
    size (int)
    text_size (string)
    bg_color (color)
    text_color (color)

Removed:
docs()

Now can hover over the library call to see docs!
Notas de Lançamento
v16

Added: docs() method didnt work
Notas de Lançamento
v17

bugdebugdebuggerdebuggingffrizzformattingfrizfrizbugfrizlabzpinepinescriptstrings

Biblioteca do Pine

De acordo com o verdadeiro espírito do TradingView, o autor publicou esse código Pine como uma biblioteca de código aberto para que outros programadores Pine de nossa comunidade possam reutilizá-lo. Parabéns ao autor! Você pode usar essa biblioteca de forma privada ou em outras publicações de código aberto, mas a reutilização desse código em uma publicação é regida pelas Regras da Casa.


Também em:

Aviso legal