PINE LIBRARY

PseudoPlot

Library "PseudoPlot"
PseudoPlot: behave like plot and fill using polyline
This library enables line plotting by polyline like plot() and fill().
The core of polyline() is array of chart.point array, polyline() is called in its method.
Moreover, plotarea() makes a box in main chart, plotting data within the box is enabled.

It works so slowy to manage array of chart.point, so limit the target to visible area of the chart.
Due to polyline specifications, na and expression can not be used for colors.

1. pseudoplot
pseudoplot() behaves like plot().


Pseudoplot has label. Label is enabled when title argument is set.
In the example bellow, "close value" label is shown with line.
The label is shown at right of the line when recent bar is visible.
It is shown at 15% from the left of visible area when recent bar is not visible.
Just set "" if you don't need label.


Arguments are designed in an order as similar as possible to plot.


2. pseudofill
pseudofill() behaves like fill().
The label is shown(text only) at right of the line when recent bar is visible.
It is shown at 10% from the left of visible area when recent bar is not visible.
Just set "" if you don't need label.


Arguments are designed in an order as similar as possible to fill.


3. plotarea and its methods
plotarea() makes a box in main chart. You can set the box position to top or bottom, and
the box height in percentage of the range of visible high and low prices.
x-coordinate of the box is from chart.left_visible_bar_time to chart.right_visible_bar_time,
y-coordinate is highest and lowest price of visible bars.
pseudoplot() and pseudofill() work as method of plotarea(box).
Usage is almost same as the function version, just set min and max value, y-coodinate is remapped automatically.
hline() is also available. The y-coordinate of hline is specified as a percentage from the bottom.
plotarea() and its associated methods are overlay=true as default.
Depending on the drawing order of the objects, plot may become invisible, so the bgcolor of plotarea should be na or tranceparent.


4. Data structure and sub methods
Array management is most imporant part of using polyline.
I don't know the proper way to handle array<chart.point>, so it is managed by array<int> and array<float> as intermediate data.
(type xy_arrays to manage bar_time and price as independent arrays.)
method cparray() pack arrays to array<chart.point>, when array includes both chart.left_visible_bar_time and chart.right_visible_bar.time.

Calling polyline is implemented as methods of array of chart.point.
Method creates polyline object if array is not empty.



Also calling label is implemented as methods of array of chart.point.
Method creates label ofject if array is not empty.
Label is located at right edge of the chart when recent bar is visible, located at left side when recent bar is invisible.




visible_xyInit(series)
  make arrays of visible x(bar_time) and y(price/value).
  Parameters:
    series (float): (float) series variable
  Returns: (xy_arrays)

method remap(this, bottom, top, min, max)
  Namespace types: xy_arrays
  Parameters:
    this (xy_arrays)
    bottom (float): (float) bottom price to ajust.
    top (float): (float) top price to ajust.
    min (float): (float) min of src value.
    max (float): (float) max of src value.
  Returns: (xy_arrays)

method polyline(this, linecolor, linewidth, linestyle, overlay)
  Namespace types: array<chart.point>
  Parameters:
    this (array<chart.point>)
    linecolor (color): (color) color of polyline.
    linewidth (int): (int) width of polyline.
    linestyle (string): (string) linestyle of polyline. default is line.style_solid("solid"), others line.style_dashed("dashed"), line.style_dotted("dotted").
    overlay (bool): (bool) force_overlay of polyline. default is false.
  Returns: (polyline)

method polyline_fill(this, fillcolor, linecolor, linewidth, linestyle, overlay)
  Namespace types: array<chart.point>
  Parameters:
    this (array<chart.point>)
    fillcolor (color)
    linecolor (color): (color) color of polyline.
    linewidth (int): (int) width of polyline.
    linestyle (string): (string) linestyle of polyline. default is line.style_solid("solid"), others line.style_dashed("dashed"), line.style_dotted("dotted").
    overlay (bool): (bool) force_overlay of polyline. default is false.
  Returns: (polyline)

method label(this, title, labelbg, labeltext, labelsize, format, shorttitle, xpos_from_left, overlay)
  Namespace types: array<chart.point>
  Parameters:
    this (array<chart.point>)
    title (string): (string) label text.
    labelbg (color): (color) color of label bg.
    labeltext (color): (color) color of label text.
    labelsize (int): (int) size of label.
    format (string): (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
    shorttitle (string): (string) another label text for recent bar is not visible.
    xpos_from_left (int): (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
    overlay (bool): (bool) force_overlay of label. default is false.
  Returns: (label)

method label_for_fill(this, title, labeltext, labelsize, format, shorttitle, xpos_from_left, overlay)
  Namespace types: array<chart.point>
  Parameters:
    this (array<chart.point>)
    title (string): (string) label text.
    labeltext (color): (color) color of label text.
    labelsize (int): (int) size of label.
    format (string): (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
    shorttitle (string): (string) another label text for recent bar is not visible.
    xpos_from_left (int): (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 10%.
    overlay (bool): (bool) force_overlay of label. default is false.
  Returns: (label)

pseudoplot(series, title, linecolor, linewidth, linestyle, labelbg, labeltext, labelsize, shorttitle, format, xpos_from_left, overlay)
  polyline like plot with label
  Parameters:
    series (float): (float) series variable to plot.
    title (string): (string) title if need label. default value is ""(disable label).
    linecolor (color): (color) color of line.
    linewidth (int): (int) width of line.
    linestyle (string): (string) style of plotting line. default is "solid", others "dashed", "dotted".
    labelbg (color): (color) color of label bg.
    labeltext (color): (color) color of label text.
    labelsize (int): (int) size of label text.
    shorttitle (string): (string) another label text for recent bar is not visible.
    format (string): (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
    xpos_from_left (int): (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
    overlay (bool): (bool) force_overlay of polyline and label.
  Returns: (pseudo_plot)

method pseudoplot(this, series, title, linecolor, linewidth, linestyle, labelbg, labeltext, labelsize, shorttitle, format, xpos_from_left, min, max, overlay)
  Namespace types: series box
  Parameters:
    this (box)
    series (float): (float) series variable to plot.
    title (string): (string) title if need label. default value is ""(disable label).
    linecolor (color): (color) color of line.
    linewidth (int): (int) width of line.
    linestyle (string): (string) style of plotting line. default is "solid", others "dashed", "dotted".
    labelbg (color): (color) color of label bg.
    labeltext (color): (color) color of label text.
    labelsize (int): (int) size of label text.
    shorttitle (string): (string) another label text for recent bar is not visible.
    format (string): (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
    xpos_from_left (int): (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
    min (float)
    max (float)
    overlay (bool): (bool) force_overlay of polyline and label.
  Returns: (pseudo_plot)

pseudofill(series1, series2, fillcolor, title, linecolor, linewidth, linestyle, labeltext, labelsize, shorttitle, format, xpos_from_left, overlay)
  fill by polyline
  Parameters:
    series1 (float): (float) series variable to plot.
    series2 (float): (float) series variable to plot.
    fillcolor (color): (color) color of fill.
    title (string)
    linecolor (color): (color) color of line.
    linewidth (int): (int) width of line.
    linestyle (string): (string) style of plotting line. default is "solid", others "dashed", "dotted".
    labeltext (color)
    labelsize (int)
    shorttitle (string)
    format (string): (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
    xpos_from_left (int): (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
    overlay (bool): (bool) force_overlay of polyline and label.
  Returns: (pseudoplot)

method pseudofill(this, series1, series2, fillcolor, title, linecolor, linewidth, linestyle, labeltext, labelsize, shorttitle, format, xpos_from_left, min, max, overlay)
  Namespace types: series box
  Parameters:
    this (box)
    series1 (float): (float) series variable to plot.
    series2 (float): (float) series variable to plot.
    fillcolor (color): (color) color of fill.
    title (string)
    linecolor (color): (color) color of line.
    linewidth (int): (int) width of line.
    linestyle (string): (string) style of plotting line. default is "solid", others "dashed", "dotted".
    labeltext (color)
    labelsize (int)
    shorttitle (string)
    format (string): (string) textformat of label. default is text.format_none("none"). others text.format_bold("bold"), text.format_italic("italic"), text.format_bold+text.format_italic("bold+italic").
    xpos_from_left (int): (int) another label x-position(percentage from left of chart width), when recent bar is not visible. default is 15%.
    min (float)
    max (float)
    overlay (bool): (bool) force_overlay of polyline and label.
  Returns: (pseudo_plot)

plotarea(pos, height, title, bordercolor, borderwidth, bgcolor, textsize, textcolor, format, overlay)
  subplot area in main chart
  Parameters:
    pos (string): (string) position of subplot area, bottom or top.
    height (int): (float) percentage of visible chart heght.
    title (string): (string) text of area box.
    bordercolor (color): (color) color of border.
    borderwidth (int): (int) width of border.
    bgcolor (color): (string) color of area bg.
    textsize (int)
    textcolor (color)
    format (string)
    overlay (bool): (bool) force_overlay of polyline and label.
  Returns: (box)

method hline(this, ypos_from_bottom, linecolor, linestyle, linewidth, overlay)
  Namespace types: series box
  Parameters:
    this (box)
    ypos_from_bottom (float): (float) percentage of box height from the bottom of box.(bottom is 0%, top is 100%).
    linecolor (color): (color) color of line.
    linestyle (string): (string) style of line.
    linewidth (int): (int) width of line.
    overlay (bool): (bool) force_overlay of polyline and label.
  Returns: (line)

pseudo_plot
  polyline and label.
  Fields:
    p (series polyline)
    l (series label)

xy_arrays
  x(bartime) and y(price or value) arrays.
  Fields:
    t (array<int>)
    p (array<float>)
FILLplotpolylinetechindicatorversion6

Perpustakaan Pine

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai satu perpustakaan sumber terbuka supaya pengaturcara Pine lain dari komuniti kami boleh menggunakannya semula. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara peribadi atau dalam penerbitan sumber terbuka lain, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman.

Penafian