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
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: [float, float, float, float]
get_pivots(int) detects high and low pivots in a series of values
Parameters:
int: _depth depth for scanning
Returns: [int, float, int, float] bar index of high pivot, high pivot, bar index of low pivot, low pivot
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
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[index]
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: [float, float, float, float]
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: [float, float, float, float]
williamFractal(int) Calculates William Fractals.
Parameters:
int: _periods Number of periods and keep a minimum value of 2 for error handling.
Returns: [bool, bool]
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
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
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: [line, bool, bool] 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
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
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
Added:
get_quote()
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
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
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
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
roundSmart(_value)
Truncates decimal points of a float value based on the amount of digits before the decimal point
Parameters:
_value (float)
Returns: float
fRound(_sample, _precision)
Returns a factor for rounding based on a sample input and a desired precision
Parameters:
_sample (float)
_precision (string)
Returns: float
get_exchangeRate(_base, _exchangeRate)
Returns a suggestion for an excgabge rate based on the base currency provided as an input to the function
Parameters:
_base (string)
_exchangeRate (float)
Returns: float
get_retracement(_high, _low, _pct_01, _pct_02, _pct_03, _pct_04, _pct_05, _pct_06, _pct_07, _pct_08, _pct_09, _pct_10)
Calculates up to 10 retracements in one go
Parameters:
_high (float)
_low (float)
_pct_01 (float)
_pct_02 (float)
_pct_03 (float)
_pct_04 (float)
_pct_05 (float)
_pct_06 (float)
_pct_07 (float)
_pct_08 (float)
_pct_09 (float)
_pct_10 (float)
Returns: array of retracement values
tostring_smart(_value)
converts a float to a string, intelligently cutting off decimal points
Parameters:
_value (float)
Returns: string
string_to_array_float(_string, _separator, _defVal)
converts a string into an array of floats
Parameters:
_string (string)
_separator (string)
_defVal (float)
Returns: array of floats
floats_to_array_of_20(f01, f02, f03, f04, f05, f06, f07, f08, f09, f10, f11, f12, f13, f14, f15, f16, f17, f18, f19, f20)
pushes 20 floats into an array and returns the array
Parameters:
f01 (float)
f02 (float)
f03 (float)
f04 (float)
f05 (float)
f06 (float)
f07 (float)
f08 (float)
f09 (float)
f10 (float)
f11 (float)
f12 (float)
f13 (float)
f14 (float)
f15 (float)
f16 (float)
f17 (float)
f18 (float)
f19 (float)
f20 (float)
Returns: array of floats
ints_to_array_of_20(i01, i02, i03, i04, i05, i06, i07, i08, i09, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20)
pushes 20 ints into an array and returns the array
Parameters:
i01 (int)
i02 (int)
i03 (int)
i04 (int)
i05 (int)
i06 (int)
i07 (int)
i08 (int)
i09 (int)
i10 (int)
i11 (int)
i12 (int)
i13 (int)
i14 (int)
i15 (int)
i16 (int)
i17 (int)
i18 (int)
i19 (int)
i20 (int)
Returns: array of ints
fillCell(_table, _column, _row, _value, _text)
Create a table cell based on params handed over
Parameters:
_table (table)
_column (int)
_row (int)
_value (float)
_text (string)
Returns: table.cell
size(_size)
Converts a string into a label size
Parameters:
_size (string)
Returns: size
position(_position)
Converts a string into a position
Parameters:
_position (string)
Returns: position
pivotFound(_dev, _isHigh, _index, _price, _color, _width, _prev_pivot_is_a_high, _lineLast, _linesCount, _devThreshold, _iLast, _pLast)
draws a line from previous pivot to next pivot
Parameters:
_dev (float)
_isHigh (bool)
_index (int)
_price (float)
_color (color)
_width (int)
_prev_pivot_is_a_high (bool)
_lineLast (line)
_linesCount (int)
_devThreshold (float)
_iLast (int)
_pLast (float)
Returns: [line, bool, bool] new line (if any), high (or no high), true if new pivot is significant according to allowed deviation threshold
get_pivots(_depth)
detects high and low pivots in a series of values
Parameters:
_depth (int)
Returns: [int, float, int, float] bar index of high pivot, high pivot, bar index of low pivot, low pivot
get_ma(_type, _src, _len, _fastLength, _slowLength, _prev_maVal, _offset, _sigma)
Gets a Moving Average based on type and source
Parameters:
_type (string)
_src (float)
_len (simple int)
_fastLength (int)
_slowLength (int)
_prev_maVal (float)
_offset (simple float)
_sigma (simple int)
Returns: A moving average with the given parameters
get_ema_ohlc(_o, _h, _l, _c, _length)
calculates EMA for 4 values based on _length. Ideal in with security call
Parameters:
_o (float)
_h (float)
_l (float)
_c (float)
_length (simple float)
Returns: [float, float, float, float]
jma(_length, _phase, _power)
calculates Jurik Moving Average
Parameters:
_length (int)
_phase (int)
_power (int)
Returns: float
getRatio_singleCandle(_index)
get ratio between current candle and candle[index]
Parameters:
_index (int)
Returns: float difference in size between current and selected candle
adx(_dilen, _adxlen)
calculates ADX for specified Legnth and Smoothing
Parameters:
_dilen (simple int)
_adxlen (simple int)
Returns: float
highestHigh_lowestLow(_h, _l, _c, _length)
calculates Highest High and lowest low within a specified length
Parameters:
_h (float)
_l (float)
_c (float)
_length (int)
Returns: [float, float, float, float]
imc(_conversionPeriods, _basePeriods, _laggingSpan2Periods)
creates values for the Ichimoku Cloud
Parameters:
_conversionPeriods (int)
_basePeriods (int)
_laggingSpan2Periods (int)
Returns: [float, float, float, float]
williamFractal(_periods)
Calculates William Fractals.
Parameters:
_periods (int)
Returns: [bool, bool]
Libreria Pine
In pieno spirito TradingView, l'autore ha pubblicato questo codice Pine come libreria open-source in modo che altri programmatori Pine della nostra comunità possano riutilizzarlo. Complimenti all'autore! È possibile utilizzare questa libreria privatamente o in altre pubblicazioni open-source, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento.
Declinazione di responsabilità
Libreria Pine
In pieno spirito TradingView, l'autore ha pubblicato questo codice Pine come libreria open-source in modo che altri programmatori Pine della nostra comunità possano riutilizzarlo. Complimenti all'autore! È possibile utilizzare questa libreria privatamente o in altre pubblicazioni open-source, ma il riutilizzo di questo codice in una pubblicazione è regolato dal nostro Regolamento.