PINE LIBRARY

MTF_Drawings

Library 'MTF_Drawings'

This library helps with drawing indicators and candle charts on all timeframes.

FEATURES
  • CHART DRAWING : Library provides functions for drawing High Time Frame (HTF) and Low Time Frame (LTF) candles.
  • INDICATOR DRAWING : Library provides functions for drawing various types of HTF and LTF indicators.
  • CUSTOM COLOR DRAWING : Library allows to color candles and indicators based on specific conditions.
  • LINEFILLS : Library provides functions for drawing linefills.


CATEGORIES
The functions are named in a way that indicates they purpose:
  • {Ind} : Function is meant only for indicators.
  • {Hist} : Function is meant only for histograms.
  • {Candle} : Function is meant only for candles.
  • {Draw} : Function draws indicators, histograms and candle charts.
  • {Populate} : Function generates necessary arrays required by drawing functions.
  • {LTF} : Function is meant only for lower timeframes.
  • {HTF} : Function is meant only for higher timeframes.
  • {D} : Function draws indicators that are composed of two lines.
  • {CC} : Function draws custom colored indicators.


USAGE
Import the library into your script.
Before using any {Draw} function it is necessary to use a {Populate} function.
Choose the appropriate one based on the category, provide the necessary arguments, and then use the {Draw} function, forwarding the arrays generated by the {Populate} function.
This doesn't apply to {Draw_Lines}, {LineFill}, or {Barcolor} functions.

EXAMPLE



FUNCTION LIST

HTF_Candle(BarsBack, BodyBear, BodyBull, BordersBear, BordersBull, WickBear, WickBull, LineStyle, BoxStyle, LineWidth, HTF_Open, HTF_High, HTF_Low, HTF_Close, HTF_Bar_Index)
  Populates two arrays with drawing data of the HTF candles.
  Parameters:
    BarsBack (int): Bars number to display.
    BodyBear (color): Candle body bear color.
    BodyBull (color): Candle body bull color.
    BordersBear (color): Candle border bear color.
    BordersBull (color): Candle border bull color.
    WickBear (color): Candle wick bear color.
    WickBull (color): Candle wick bull color.
    LineStyle (string): Wick style (Solid-Dotted-Dashed).
    BoxStyle (string): Border style (Solid-Dotted-Dashed).
    LineWidth (int): Wick width.
    HTF_Open (float): HTF open price.
    HTF_High (float): HTF high price.
    HTF_Low (float): HTF low price.
    HTF_Close (float): HTF close price.
    HTF_Bar_Index (int): HTF bar_index.
  Returns: Two arrays with drawing data of the HTF candles.

LTF_Candle(BarsBack, BodyBear, BodyBull, BordersBear, BordersBull, WickBear, WickBull, LineStyle, BoxStyle, LineWidth, LTF_Open, LTF_High, LTF_Low, LTF_Close)
  Populates two arrays with drawing data of the LTF candles.
  Parameters:
    BarsBack (int): Bars number to display.
    BodyBear (color): Candle body bear color.
    BodyBull (color): Candle body bull color.
    BordersBear (color): Candle border bear color.
    BordersBull (color): Candle border bull color.
    WickBear (color): Candle wick bear color.
    WickBull (color): Candle wick bull color.
    LineStyle (string): Wick style (Solid-Dotted-Dashed).
    BoxStyle (string): Border style (Solid-Dotted-Dashed).
    LineWidth (int): Wick width.
    LTF_Open (float[]): LTF open price.
    LTF_High (float[]): LTF high price.
    LTF_Low (float[]): LTF low price.
    LTF_Close (float[]): LTF close price.
  Returns: Two arrays with drawing data of the LTF candles.

Draw_Candle(Box, Line, Offset)
  Draws HTF or LTF candles.
  Parameters:
    Box (box[]): Box array with drawing data.
    Line (line[]): Line array with drawing data.
    Offset (int): Offset of the candles.
  Returns: Drawing of the candles.

Populate_HTF_Ind(IndValue, BarsBack, IndColor, HTF_Bar_Index)
  Populates one array with drawing data of the HTF indicator.
  Parameters:
    IndValue (float): Indicator value.
    BarsBack (int): Indicator lines to display.
    IndColor (color): Indicator color.
    HTF_Bar_Index (int): HTF bar_index.
  Returns: An array with drawing data of the HTF indicator.

Populate_LTF_Ind(IndValue, BarsBack, IndColor)
  Populates one array with drawing data of the LTF indicator.
  Parameters:
    IndValue (float[]): Indicator value.
    BarsBack (int): Indicator lines to display.
    IndColor (color): Indicator color.
  Returns: An array with drawing data of the LTF indicator.

Draw_Ind(Line, Mult, Exe)
  Draws one HTF or LTF indicator.
  Parameters:
    Line (line[]): Line array with drawing data.
    Mult (int): Coordinates multiplier.
    Exe (bool): Display the indicator.
  Returns: Drawing of the indicator.

Populate_HTF_Ind_D(IndValue_1, IndValue_2, BarsBack, IndColor_1, IndColor_2, HTF_Bar_Index)
  Populates two arrays with drawing data of the HTF indicators.
  Parameters:
    IndValue_1 (float): First indicator value.
    IndValue_2 (float): Second indicator value.
    BarsBack (int): Indicator lines to display.
    IndColor_1 (color): First indicator color.
    IndColor_2 (color): Second indicator color.
    HTF_Bar_Index (int): HTF bar_index.
  Returns: Two arrays with drawing data of the HTF indicators.

Populate_LTF_Ind_D(IndValue_1, IndValue_2, BarsBack, IndColor_1, IndColor_2)
  Populates two arrays with drawing data of the LTF indicators.
  Parameters:
    IndValue_1 (float[]): First indicator value.
    IndValue_2 (float[]): Second indicator value.
    BarsBack (int): Indicator lines to display.
    IndColor_1 (color): First indicator color.
    IndColor_2 (color): Second indicator color.
  Returns: Two arrays with drawing data of the LTF indicators.

Draw_Ind_D(Line_1, Line_2, Mult, Exe_1, Exe_2)
  Draws two LTF or HTF indicators.
  Parameters:
    Line_1 (line[]): First line array with drawing data.
    Line_2 (line[]): Second line array with drawing data.
    Mult (int): Coordinates multiplier.
    Exe_1 (bool): Display the first indicator.
    Exe_2 (bool): Display the second indicator.
  Returns: Drawings of the indicators.

Barcolor(Box, Line, BarColor)
  Colors the candles based on indicators output.
  Parameters:
    Box (box[]): Candle box array.
    Line (line[]): Candle line array.
    BarColor (color[]): Indicator color array.
  Returns: Colored candles.

Populate_HTF_Ind_D_CC(IndValue_1, IndValue_2, BarsBack, BullColor, BearColor, IndColor_1, HTF_Bar_Index)
  Populates two array with drawing data of the HTF indicators with color based on: IndValue_1 >= IndValue_2 ? BullColor : BearColor.
  Parameters:
    IndValue_1 (float): First indicator value.
    IndValue_2 (float): Second indicator value.
    BarsBack (int): Indicator lines to display.
    BullColor (color): Bull color.
    BearColor (color): Bear color.
    IndColor_1 (color): First indicator color.
    HTF_Bar_Index (int): HTF bar_index.
  Returns: Three arrays with drawing and color data of the HTF indicators.

Populate_LTF_Ind_D_CC(IndValue_1, IndValue_2, BarsBack, BullColor, BearColor, IndColor_1)
  Populates two arrays with drawing data of the LTF indicators with color based on: IndValue_1 >= IndValue_2 ? BullColor : BearColor.
  Parameters:
    IndValue_1 (float[]): First indicator value.
    IndValue_2 (float[]): Second indicator value.
    BarsBack (int): Indicator lines to display.
    BullColor (color): Bull color.
    BearColor (color): Bearcolor.
    IndColor_1 (color): First indicator color.
  Returns: Three arrays with drawing and color data of the LTF indicators.

Populate_HTF_Hist_CC(HistValue, IndValue_1, IndValue_2, BarsBack, BullColor, BearColor, HTF_Bar_Index)
  Populates one array with drawing data of the HTF histogram with color based on: IndValue_1 >= IndValue_2 ? BullColor : BearColor.
  Parameters:
    HistValue (float): Indicator value.
    IndValue_1 (float): First indicator value.
    IndValue_2 (float): Second indicator value.
    BarsBack (int): Indicator lines to display.
    BullColor (color): Bull color.
    BearColor (color): Bearcolor.
    HTF_Bar_Index (int): HTF bar_index
  Returns: Two arrays with drawing and color data of the HTF histogram.

Populate_LTF_Hist_CC(HistValue, IndValue_1, IndValue_2, BarsBack, BullColor, BearColor)
  Populates one array with drawing data of the LTF histogram with color based on: IndValue_1 >= IndValue_2 ? BullColor : BearColor.
  Parameters:
    HistValue (float[]): Indicator value.
    IndValue_1 (float[]): First indicator value.
    IndValue_2 (float[]): Second indicator value.
    BarsBack (int): Indicator lines to display.
    BullColor (color): Bull color.
    BearColor (color): Bearcolor.
  Returns: Two array with drawing and color data of the LTF histogram.

Populate_LTF_Hist_CC_VA(HistValue, Value, BarsBack, BullColor, BearColor)
  Populates one array with drawing data of the LTF histogram with color based on: HistValue >= Value ? BullColor : BearColor.
  Parameters:
    HistValue (float[]): Indicator value.
    Value (float): First indicator value.
    BarsBack (int): Indicator lines to display.
    BullColor (color): Bull color.
    BearColor (color): Bearcolor.
  Returns: Two array with drawing and color data of the LTF histogram.

Populate_HTF_Ind_CC(IndValue, IndValue_1, BarsBack, BullColor, BearColor, HTF_Bar_Index)
  Populates one array with drawing data of the HTF indicator with color based on: IndValue >= IndValue_1 ? BullColor : BearColor.
  Parameters:
    IndValue (float): Indicator value.
    IndValue_1 (float): Second indicator value.
    BarsBack (int): Indicator lines to display.
    BullColor (color): Bull color.
    BearColor (color): Bearcolor.
    HTF_Bar_Index (int): HTF bar_index
  Returns: Two arrays with drawing and color data of the HTF indicator.

Populate_LTF_Ind_CC(IndValue, IndValue_1, BarsBack, BullColor, BearColor)
  Populates one array with drawing data of the LTF indicator with color based on: IndValue >= IndValue_1 ? BullColor : BearColor.
  Parameters:
    IndValue (float[]): Indicator value.
    IndValue_1 (float[]): Second indicator value.
    BarsBack (int): Indicator lines to display.
    BullColor (color): Bull color.
    BearColor (color): Bearcolor.
  Returns: Two arrays with drawing and color data of the LTF indicator.

Draw_Lines(BarsBack, y1, y2, LineType, Fill)
  Draws price lines on indicators.
  Parameters:
    BarsBack (int): Indicator lines to display.
    y1 (float): Coordinates of the first line.
    y2 (float): Coordinates of the second line.
    LineType (string): Line type.
    Fill (color): Fill color.
  Returns: Drawing of the lines.

LineFill(Upper, Lower, BarsBack, FillColor)
  Fills two lines with linefill HTF or LTF.
  Parameters:
    Upper (line[]): Upper line.
    Lower (line[]): Lower line.
    BarsBack (int): Indicator lines to display.
    FillColor (color): Fill color.
  Returns: Linefill of the lines.

Populate_LTF_Hist(HistValue, BarsBack, HistColor)
  Populates one array with drawing data of the LTF histogram.
  Parameters:
    HistValue (float[]): Indicator value.
    BarsBack (int): Indicator lines to display.
    HistColor (color): Indicator color.
  Returns: One array with drawing data of the LTF histogram.

Populate_HTF_Hist(HistValue, BarsBack, HistColor, HTF_Bar_Index)
  Populates one array with drawing data of the HTF histogram.
  Parameters:
    HistValue (float): Indicator value.
    BarsBack (int): Indicator lines to display.
    HistColor (color): Indicator color.
    HTF_Bar_Index (int): HTF bar_index.
  Returns: One array with drawing data of the HTF histogram.

Draw_Hist(Box, Mult, Exe)
  Draws HTF or LTF histogram.
  Parameters:
    Box (box[]): Box Array.
    Mult (int): Coordinates multiplier.
    Exe (bool): Display the histogram.
  Returns: Drawing of the histogram.
arraysmtf

Thư viện Pine

Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ.

Thông báo miễn trừ trách nhiệm