corny2000

Punchline_Lib

Library "Punchline_Lib"

roundSmart(float) Truncates decimal points of a float value based on the amount of digits before the decimal point
  Parameters:
    float: _value any number
  Returns: float

tostring_smart(float) converts a float to a string, intelligently cutting off decimal points
  Parameters:
    float: _value any number
  Returns: string
Release Notes: v2

Added:
get_ema_ohlc(float, float, float, float, float) calculates EMA for 4 values based on _length. Ideal in with security call
  Parameters:
    float: _o open
    float: _h high
    float: _l low
    float: _c close
    float: _length length
  Returns:

get_pivots(int) detects high and low pivots in a series of values
  Parameters:
    int: _depth depth for scanning
  Returns: bar index of high pivot, high pivot, bar index of low pivot, low pivot
Release Notes: v3

Added:
get_ma(string, string, int, int, int, float, float, int) Gets a Moving Average based on type and source
  Parameters:
    string: _type The type of MA
    string: _src The source for the MA (open, high, low or close); default=close
    int: _len The MA period
    int: _fastLength Fast EMA Length (AMA only)
    int: _slowLength Slow EMA Length (AMA only)
    float: _prev_maVal Previous MA value (AMA only)
    float: _offset Offset for ALMA calculation (ALMA only)
    int: _sigma Sigma for ALMA calculation (ALMA only)
  Returns: A moving average with the given parameters
Release Notes: v4

Added:
jma(int, int, int) calculates Jurik Moving Average
  Parameters:
    int: _length Length
    int: _phase Phase
    int: _power Power
  Returns: float

getRatio_singleCandle(int) get ratio between current candle and candle
  Parameters:
    int: _index index of the candle you want to compare the current candle to
  Returns: float difference in size between current and selected candle

adx(int, int) calculates ADX for specified Legnth and Smoothing
  Parameters:
    int: _dilen ADX DI Length
    int: _adxlen ADX Smoothing
  Returns: float

highestHigh_lowestLow(series, series, series, int) calculates Highest High and lowest low within a specified length
  Parameters:
    series: float h high
    series: float l low
    series: float c close
    int: _length Length to scan for values
  Returns:
Release Notes: v5

Added:
imc(int, int, int) creates values for the Ichimoku Cloud
  Parameters:
    int: _conversionPeriods Conversion Periods
    int: _basePeriods Base Periods
    int: _laggingSpan2Periods Lagging Span Periods
  Returns:

williamFractal(int) Calculates William Fractals.
  Parameters:
    int: _periods Number of periods and keep a minimum value of 2 for error handling.
  Returns:
Release Notes: v6

Updated:
get_ma(string, series, simple, int, int, float, simple, int) Gets a Moving Average based on type and source
  Parameters:
    string: _type The type of MA
    series: float _src The source for the MA
    simple: int _len The MA period
    int: _fastLength Fast EMA Length (AMA only)
    int: _slowLength Slow EMA Length (AMA only)
    float: _prev_maVal Previous MA value (AMA only)
    simple: float _offset Offset for ALMA/LSMA calculation (ALMA and LSMA only)
    int: _sigma Sigma for ALMA calculation (ALMA only)
  Returns: A moving average with the given parameters
Release Notes: v7

Added:
f_string_to_array_float(string, string, float) converts a string into an array of floats
  Parameters:
    string: _string input string to be converted
    string: _delimiter delimiter to separate string by
    float: _defVal default value in case no content is found
  Returns: array of floats

f_fillCell(table, int, int, float, string) Create a table cell based on params handed over
  Parameters:
    table: _table Table to be edited
    int: _column column of cell to be edited
    int: _row row of cell to be edited
    float: _value value to be added into cell
    string: _text text to be added into cell
  Returns: table.cell
Release Notes: v8

Added:
string_to_array_float(string, string, float) converts a string into an array of floats
  Parameters:
    string: _string input string to be converted
    string: _delimiter delimiter to separate string by
    float: _defVal default value in case no content is found
  Returns: array of floats

pivotFound(float, bool, int, float, color, int, bool, line, int, float, int, float) draws a line from previous pivot to next pivot
  Parameters:
    float: _dev deviation
    bool: _isHigh true if to be processed coordinate is a high, false otherwise
    int: _index index of next price to process
    float: _price new price to be evaluated
    color: _color color for drawing line from one pivot to another pivot (#00000000 to draw no line)
    int: _width width of line for lines
    bool: _prev_pivot_is_a_high true if to previous pivot is a high, false otherwise
    line: _lineLast id of previous line
    int: _linesCount counter of how many lines have been drawn so far
    float: _devThreshold allowed deviation
    int: _iLast index of previous pivot point
    float: _pLast price of previous pivot point
  Returns: new line (if any), high (or no high), true if new pivot is significant according to allowed deviation threshold

Removed:
f_string_to_array_float(string, string, float) converts a string into an array of floats
Release Notes: v9

Added:
fillCell(table, int, int, float, string) Create a table cell based on params handed over
  Parameters:
    table: _table Table to be edited
    int: _column column of cell to be edited
    int: _row row of cell to be edited
    float: _value value to be added into cell
    string: _text text to be added into cell
  Returns: table.cell

Updated:
string_to_array_float(string, string, float) converts a string into an array of floats
  Parameters:
    string: _string input string to be converted
    string: _separator separator to separate string by
    float: _defVal default value in case no content is found
  Returns: array of floats

Removed:
f_fillCell(table, int, int, float, string) Create a table cell based on params handed over
Release Notes: v10

Added:
fRound(float, string) Returns a factor for rounding based on a sample input and a desired precision
  Parameters:
    float: _sample sample input to give an idea for the number setup
    string: _precision desired precision (zero, max, low, high)
  Returns: float
Release Notes: v11

Added:
get_quote()
Release Notes: v12
Release Notes: v13

Added:
get_exchangeRate(string, float) Returns a suggestion for an excgabge rate based on the base currency provided as an input to the function
  Parameters:
    string: _base symbol of the base currency to produce a quote currency against
    float: _exchangeRate alternative exchange Rate if no better can be determined
  Returns: float

Removed:
get_quote(string) Returns a suggestion for a matching quote currency regarding the base currency provided as an input to the function
Release Notes: v14
Release Notes: v15

Added:
size(string) Converts a string into a label size
  Parameters:
    string: _size the desired size as string
  Returns: size

position(string) Converts a string into a position
  Parameters:
    string: _position the desired position as string
  Returns: position
Release Notes: v16

Added:
floats_to_array_of_20(float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float, float) pushes 20 floats into an array and returns the array
  Parameters:
    float: f01 float to push into the array
    float: f02 float to push into the array
    float: f03 float to push into the array
    float: f04 float to push into the array
    float: f05 float to push into the array
    float: f06 float to push into the array
    float: f07 float to push into the array
    float: f08 float to push into the array
    float: f09 float to push into the array
    float: f10 float to push into the array
    float: f11 float to push into the array
    float: f12 float to push into the array
    float: f13 float to push into the array
    float: f14 float to push into the array
    float: f15 float to push into the array
    float: f16 float to push into the array
    float: f17 float to push into the array
    float: f18 float to push into the array
    float: f19 float to push into the array
    float: f20 float to push into the array
  Returns: array of floats

ints_to_array_of_20(int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int) pushes 20 ints into an array and returns the array
  Parameters:
    int: i01 int to push into the array
    int: i02 int to push into the array
    int: i03 int to push into the array
    int: i04 int to push into the array
    int: i05 int to push into the array
    int: i06 int to push into the array
    int: i07 int to push into the array
    int: i08 int to push into the array
    int: i09 int to push into the array
    int: i10 int to push into the array
    int: i11 int to push into the array
    int: i12 int to push into the array
    int: i13 int to push into the array
    int: i14 int to push into the array
    int: i15 int to push into the array
    int: i16 int to push into the array
    int: i17 int to push into the array
    int: i18 int to push into the array
    int: i19 int to push into the array
    int: i20 int to push into the array
  Returns: array of ints
Release Notes: v17

Added:
get_retracement(float, float, float, float, float, float, float, float, float, float, float, float) Calculates up to 10 retracements in one go
  Parameters:
    float: _high high value
    float: _low low value
    float: _pct_01 retracement %
    float: _pct_02 retracement %
    float: _pct_03 retracement %
    float: _pct_04 retracement %
    float: _pct_05 retracement %
    float: _pct_06 retracement %
    float: _pct_07 retracement %
    float: _pct_08 retracement %
    float: _pct_09 retracement %
    float: _pct_10 retracement %
  Returns: array of retracement values
Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House Rules.

Frånsägelse av ansvar

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this library?

Copy the following line and paste it in your script.