Library "X"
a collection of 'special' methods/functions ('special' at the time of conception)
Initial functions includes:
• count of a given number in a given array
• array.get() but option added to use negative index
• sum of all digits until the output < 10
• slope/angle calculation of lines
method count_num_in_array(arr, num)
counts how many times a given number is present in a given array (0 when not present)
Namespace types: int[]
Parameters:
arr (int[]): Array (int, float[])
num (int): Number that needs to be counted (int, float)
Returns: count of number in array (0 when not present)
method count_num_in_array(arr, num)
Namespace types: float[]
Parameters:
arr (float[])
num (float)
method get_(arr, idx)
array.get() but you can use negative index (-1 is last of array, -2 is second last,...)
Namespace types: int[]
Parameters:
arr (int[]): Array (int, float, string, bool, label, line, box, color[])
idx (int): Index
Returns: value/object at index, 'na' if index is outside array
method get_(arr, idx)
Namespace types: float[]
Parameters:
arr (float[])
idx (int)
method get_(arr, idx)
Namespace types: string[]
Parameters:
arr (string[])
idx (int)
method get_(arr, idx)
Namespace types: bool[]
Parameters:
arr (bool[])
idx (int)
method get_(arr, idx)
Namespace types: label[]
Parameters:
arr (label[])
idx (int)
method get_(arr, idx)
Namespace types: line[]
Parameters:
arr (line[])
idx (int)
method get_(arr, idx)
Namespace types: box[]
Parameters:
arr (box[])
idx (int)
method get_(arr, idx)
Namespace types: color[]
Parameters:
arr (color[])
idx (int)
method sumAllNumbers_till_under_10(num)
sums all separate digit numbers, it repeats the process until sum < 10
Namespace types: series int, simple int, input int, const int
Parameters:
num (int): Number (int, float)
Returns: value between 0 and 9
method sumAllNumbers_till_under_10(num)
Namespace types: series float, simple float, input float, const float
Parameters:
num (float)
method XYaxis(width)
Global function to calculate Yaxis, which is used in calculate_slope() method
Namespace types: series int, simple int, input int, const int
Parameters:
width (int): Amount of bars for reference X-axis
Returns: Yaxis
method calculate_slope(width, XYratio, Yaxis, x1, y1, x2, y2)
Returns a normalised slope
Namespace types: series int, simple int, input int, const int
Parameters:
width (int): Amount of bars to calculate height
XYratio (float): Ratio to calculate height (from width) normalised_slope calculation
Yaxis (float): Y-axis from XYaxis() method
x1 (int): x1 of line
y1 (float): y1 of line
x2 (int): x2 of line
y2 (float): y2 of line
Returns: Tuple of [slope, angle] -> slope = price difference per bar