MathExtensionLibrary "MathExtension"
Math Extension.
log2(_value) calculate log base 2
Parameters:
_value : float, number.
Returns: float, base 2 logarithm of value.
fmod(numerator, denominator) float remainder of x divided by y.
Parameters:
numerator : float, division numerator.
denominator : float, division denuminator.
Returns: float
fractional(value) computes the fractional part of the argument value.
Parameters:
value : float, value to compute.
Returns: float, fractional part.
integral(value) Find the integral of value.
Parameters:
value : float, value.
Returns: float.
atan2(value_x, value_y) Approximation to atan2 calculation, arc tangent of y/ x in the range (-pi,pi) radians.
Parameters:
value_x : float, value x.
value_y : float, value y.
Returns: float, value with angle in radians. (negative if quadrante 3 or 4)
hypotenuse(value_x, value_y) Multidimensional euclidean distance from the origin to a point.
Parameters:
value_x : float, value x.
value_y : float, value y.
Returns: float
near_equal(value_a, value_b, relative_tolerance, absolute_tolerance) Determine whether two floating point numbers are near in value.
Parameters:
value_a : float, value to compare with.
value_b : float, value to be compared against.
relative_tolerance : float, default (1.0e-09).
absolute_tolerance : float, default (0.0).
Returns: bool
factorize(value) Factorize a number.
Parameters:
value : int, positive number.
Returns: int
permutations(options_size, combo_size) Number of ways to choose k items from n items without repetition and with order.
Parameters:
options_size : int, number of items to pool from
combo_size : int, number of items to be chosen
Returns: int
combinations(options_size, combo_size) Find the total number of possibilities to choose k things from n items
Parameters:
options_size : int, number of items to pool from
combo_size : int, number of items to be chosen
Returns: int
Indicators and strategies
MathConstantsUniversalLibrary "MathConstantsUniversal"
Mathematical Constants
SpeedOfLight() Speed of Light in Vacuum: c_0 = 2.99792458e8 (defined, exact; 2007 CODATA)
MagneticPermeability() Magnetic Permeability in Vacuum: mu_0 = 4*Pi * 10^-7 (defined, exact; 2007 CODATA)
ElectricPermittivity() Electric Permittivity in Vacuum: epsilon_0 = 1/(mu_0*c_0^2) (defined, exact; 2007 CODATA)
CharacteristicImpedanceVacuum() Characteristic Impedance of Vacuum: Z_0 = mu_0*c_0 (defined, exact; 2007 CODATA)
GravitationalConstant() Newtonian Constant of Gravitation: G = 6.67429e-11 (2007 CODATA)
PlancksConstant() Planck's constant: h = 6.62606896e-34 (2007 CODATA)
DiracsConstant() Reduced Planck's constant: h_bar = h / (2*Pi) (2007 CODATA)
PlancksMass() Planck mass: m_p = (h_bar*c_0/G)^(1/2) (2007 CODATA)
PlancksTemperature() Planck temperature: T_p = (h_bar*c_0^5/G)^(1/2)/k (2007 CODATA)
PlancksLength() Planck length: l_p = h_bar/(m_p*c_0) (2007 CODATA)
PlancksTime() Planck time: t_p = l_p/c_0 (2007 CODATA)
MathConstantsScientificLibrary "MathConstantsScientific"
Mathematical Constants
Yotta() The SI prefix factor corresponding to 1 000 000 000 000 000 000 000 000
Zetta() The SI prefix factor corresponding to 1 000 000 000 000 000 000 000
Exa() The SI prefix factor corresponding to 1 000 000 000 000 000 000
Peta() The SI prefix factor corresponding to 1 000 000 000 000 000
Tera() The SI prefix factor corresponding to 1 000 000 000 000
Giga() The SI prefix factor corresponding to 1 000 000 000
Mega() The SI prefix factor corresponding to 1 000 000
Kilo() The SI prefix factor corresponding to 1 000
Hecto() The SI prefix factor corresponding to 100
Deca() The SI prefix factor corresponding to 10
Deci() The SI prefix factor corresponding to 0.1
Centi() The SI prefix factor corresponding to 0.01
Milli() The SI prefix factor corresponding to 0.001
Micro() The SI prefix factor corresponding to 0.000 001
Nano() The SI prefix factor corresponding to 0.000 000 001
Pico() The SI prefix factor corresponding to 0.000 000 000 001
Femto() The SI prefix factor corresponding to 0.000 000 000 000 001
Atto() The SI prefix factor corresponding to 0.000 000 000 000 000 001
Zepto() The SI prefix factor corresponding to 0.000 000 000 000 000 000 001
Yocto() The SI prefix factor corresponding to 0.000 000 000 000 000 000 000 001
MathConstantsElectromagneticLibrary "MathConstantsElectromagnetic"
Mathematical Constants
ElementaryCharge() Elementary Electron Charge: e = 1.602176487e-19 (2007 CODATA)
MagneticFluxQuantum() Magnetic Flux Quantum: theta_0 = h/(2*e) (2007 CODATA)
ConductanceQuantum() Conductance Quantum: G_0 = 2*e^2/h (2007 CODATA)
JosephsonConstant() Josephson Constant: K_J = 2*e/h (2007 CODATA)
VonKlitzingConstant() Von Klitzing Constant: R_K = h/e^2 (2007 CODATA)
BohrMagneton() Bohr Magneton: mu_B = e*h_bar/2*m_e (2007 CODATA)
NuclearMagneton() Nuclear Magneton: mu_N = e*h_bar/2*m_p (2007 CODATA)
MathConstantsAtomicLibrary "MathConstantsAtomic"
Mathematical Constants
FineStructureConstant() Fine Structure Constant: alpha = e^2/4*Pi*e_0*h_bar*c_0 (2007 CODATA)
RydbergConstant() Rydberg Constant: R_infty = alpha^2*m_e*c_0/2*h (2007 CODATA)
BohrRadius() Bor Radius: a_0 = alpha/4*Pi*R_infty (2007 CODATA)
HartreeEnergy() Hartree Energy: E_h = 2*R_infty*h*c_0 (2007 CODATA)
QuantumOfCirculation() Quantum of Circulation: h/2*m_e (2007 CODATA)
FermiCouplingConstant() Fermi Coupling Constant: G_F/(h_bar*c_0)^3 (2007 CODATA)
WeakMixingAngle() Weak Mixin Angle: sin^2(theta_W) (2007 CODATA)
ElectronMass() Electron Mass: (2007 CODATA)
ElectronMassEnergyEquivalent() Electron Mass Energy Equivalent: (2007 CODATA)
ElectronMolarMass() Electron Molar Mass: (2007 CODATA)
ComptonWavelength() Electron Compton Wavelength: (2007 CODATA)
ClassicalElectronRadius() Classical Electron Radius: (2007 CODATA)
ThomsonCrossSection() Thomson Cross Section: (2002 CODATA)
ElectronMagneticMoment() Electron Magnetic Moment: (2007 CODATA)
ElectronGFactor() Electon G-Factor: (2007 CODATA)
MuonMass() Muon Mass: (2007 CODATA)
MuonMassEnegryEquivalent() Muon Mass Energy Equivalent: (2007 CODATA)
MuonMolarMass() Muon Molar Mass: (2007 CODATA)
MuonComptonWavelength() Muon Compton Wavelength: (2007 CODATA)
MuonMagneticMoment() Muon Magnetic Moment: (2007 CODATA)
MuonGFactor() Muon G-Factor: (2007 CODATA)
TauMass() Tau Mass: (2007 CODATA)
TauMassEnergyEquivalent() Tau Mass Energy Equivalent: (2007 CODATA)
TauMolarMass() Tau Molar Mass: (2007 CODATA)
TauComptonWavelength() Tau Compton Wavelength: (2007 CODATA)
ProtonMass() Proton Mass: (2007 CODATA)
ProtonMassEnergyEquivalent() Proton Mass Energy Equivalent: (2007 CODATA)
ProtonMolarMass() Proton Molar Mass: (2007 CODATA)
ProtonComptonWavelength() Proton Compton Wavelength: (2007 CODATA)
ProtonMagneticMoment() Proton Magnetic Moment: (2007 CODATA)
ProtonGFactor() Proton G-Factor: (2007 CODATA)
ShieldedProtonMagneticMoment() Proton Shielded Magnetic Moment: (2007 CODATA)
ProtonGyromagneticRatio() Proton Gyro-Magnetic Ratio: (2007 CODATA)
ShieldedProtonGyromagneticRatio() Proton Shielded Gyro-Magnetic Ratio: (2007 CODATA)
NeutronMass() Neutron Mass: (2007 CODATA)
NeutronMassEnegryEquivalent() Neutron Mass Energy Equivalent: (2007 CODATA)
NeutronMolarMass() Neutron Molar Mass: (2007 CODATA)
NeutronComptonWavelength() Neuron Compton Wavelength: (2007 CODATA)
NeutronMagneticMoment() Neutron Magnetic Moment: (2007 CODATA)
NeutronGFactor() Neutron G-Factor: (2007 CODATA)
NeutronGyromagneticRatio() Neutron Gyro-Magnetic Ratio: (2007 CODATA)
DeuteronMass() Deuteron Mass: (2007 CODATA)
DeuteronMassEnegryEquivalent() Deuteron Mass Energy Equivalent: (2007 CODATA)
DeuteronMolarMass() Deuteron Molar Mass: (2007 CODATA)
DeuteronMagneticMoment() Deuteron Magnetic Moment: (2007 CODATA)
HelionMass() Helion Mass: (2007 CODATA)
HelionMassEnegryEquivalent() Helion Mass Energy Equivalent: (2007 CODATA)
HelionMolarMass() Helion Molar Mass: (2007 CODATA)
Avogadro() Avogadro constant: (2010 CODATA)
NumberOfSharesBuyLibrary "NumberOfSharesBuy"
Library for the number of shares purchased
SizeCalc(totalAssets, unit, lossPercent, maxLossPerShere) Calculate the number of shares to be purchased from the initial capital and the maximum loss per share
Parameters:
totalAssets : Initial capital
unit : A unit of the number of shares to be traded in one trade
lossPercent : What percentage of loss is allowed in one loss cut
maxLossPerShere : Maximum loss per share
Returns: Number of shares purchased
=====================================
ライブラリ "株数に関するライブラリ"
SizeCalc(totalAssets, unit, lossPercent, maxLossPerShere) 初期資本と一株当たり最大損失から購入株数を求める
引数一覧:
totalAssets : 初期資本
unit : 一回のトレードで行う株数の単位
lossPercent : 一回の損切で何%までの損失を許容するか
maxLossPerShere : 一株当たり最大損失
戻り値: 購入株数
enhanced_taLibrary "enhanced_ta"
Collection of all custom and enhanced TA indicators
ma(source, maType, length) returns custom moving averages
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow
length : Moving Average Length
Returns: moving average for the given type and length
bb(source, maType, length, multiplier) returns Bollinger band for custom moving average
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow
length : Moving Average Length
multiplier : Standard Deviation multiplier
Returns: Bollinger band with custom moving average for given source, length and multiplier
bbw(source, maType, length, multiplier) returns Bollinger bandwidth for custom moving average
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow
length : Moving Average Length
multiplier : Standard Deviation multiplier
Returns: Bollinger Bandwidth for custom moving average for given source, length and multiplier
bpercentb(source, maType, length, multiplier) returns Bollinger Percent B for custom moving average
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow
length : Moving Average Length
multiplier : Standard Deviation multiplier
Returns: Bollinger Percent B for custom moving average for given source, length and multiplier
kc(source, maType, length, multiplier) returns Keltner Channel for custom moving average
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow
length : Moving Average Length
multiplier : Standard Deviation multiplier
Returns: Keltner Channel for custom moving average for given souce, length and multiplier
kcw(source, maType, length, multiplier) returns Keltner Channel Width with custom moving average
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow
length : Moving Average Length
multiplier : Standard Deviation multiplier
Returns: Keltner Channel Width for custom moving average
kpercentk(source, maType, length, multiplier) returns Keltner Channel Percent K Width with custom moving average
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow
length : Moving Average Length
multiplier : Standard Deviation multiplier
Returns: Keltner Percent K for given moving average, source, length and multiplier
dc(source, useCustomSource, length) returns Custom Donchian Channel
Parameters:
source : - Custom source
useCustomSource : - Custom source is used only if useCustomSource is set to true
length : - donchian channel length
Returns: Donchian channel
oscillatorRange(source, method, highlowLength, rangeLength) returns Custom overbought/oversold areas for an oscillator input
Parameters:
source : - Osillator source such as RSI, COG etc.
method : - Valid values for method are : sma, ema, hma, rma, wma, vwma, swma, highlow
highlowLength : - length on which highlow of the oscillator is calculated
rangeLength : - length used for calculating oversold/overbought range - usually same as oscillator length
Returns: Dynamic overbought and oversold range for oscillator input
RSLibrary "RS"
Utility methods for Relative Strength analysis
This is the first library test publication with ratio() method. More functions will be added.
ratio(symbol, benchmark) Simple ratio of symbol vs benchmark
Parameters:
symbol : to be compared
benchmark : to be compared
Returns: ratio of symbol to benchmark
bursamalaysianonshariahLibrary "bursamalaysianonshariah"
List of non-Shariah stock for Bursa Malaysia as of Oct 2021
No parameter required
status() will return 1 if ticker in the list, 0 if ticker not in the list and 2 if ticker not from Bursa Malaysia
Example usage :
//@version=5
indicator("My Script", overlay = true)
import BURSATRENDBANDCHART/bursamalaysianonshariah/1 as b
bgcolor(status() == 1 ? color.new(color.red, 90) : status() == 0 ? color.new(color.green, 90) : color.new(color.blue, 90))
Special thanks to
wmsafwan
RozaniGhani-RG
Vector2OperationsLibrary "Vector2Operations"
functions to handle vector2 operations.
math_fractional(_value) computes the fractional part of the argument value.
Parameters:
_value : float, value to compute.
Returns: float, fractional part.
atan2(_a) Approximation to atan2 calculation, arc tangent of y/ x in the range radians.
Parameters:
_a : vector2 in the form of a array .
Returns: float, value with angle in radians. (negative if quadrante 3 or 4)
set_x(_a, _value) Set the x value of vector _a.
Parameters:
_a : vector2 in the form of a array .
_value : value to replace x value of _a.
Returns: void Modifies vector _a.
set_y(_a, _value) Set the y value of vector _a.
Parameters:
_a : vector in the form of a array .
_value : value to replace y value of _a.
Returns: void Modifies vector _a.
get_x(_a) Get the x value of vector _a.
Parameters:
_a : vector in the form of a array .
Returns: float, x value of the vector _a.
get_y(_a) Get the y value of vector _a.
Parameters:
_a : vector in the form of a array .
Returns: float, y value of the vector _a.
get_xy(_a) Return the tuple of vector _a in the form
Parameters:
_a : vector2 in the form of a array .
Returns:
length_squared(_a) Length of vector _a in the form. , for comparing vectors this is computationaly lighter.
Parameters:
_a : vector in the form of a array .
Returns: float, squared length of vector.
length(_a) Magnitude of vector _a in the form.
Parameters:
_a : vector in the form of a array .
Returns: float, Squared length of vector.
vmin(_a) Lowest element of vector.
Parameters:
_a : vector in the form of a array .
Returns: float
vmax(_a) Highest element of vector.
Parameters:
_a : vector in the form of a array .
Returns: float
from(_value) Assigns value to a new vector x,y elements.
Parameters:
_value : x and y value of the vector. optional.
Returns: float vector.
new(_x, _y) Creates a prototype array to handle vectors.
Parameters:
_x : float, x value of the vector. optional.
_y : float, y number of the vector. optional.
Returns: float vector.
down() Vector in the form . Returns: float vector.
left() Vector in the form . Returns: float vector.
one() Vector in the form . Returns: float vector.
right() Vector in the form . Returns: float vector
up() Vector in the form . Returns: float vector
zero() Vector in the form . Returns: float vector
add(_a, _b) Adds vector _b to _a, in the form
.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns:
subtract(_a, _b) Subtract vector _b from _a, in the form
.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns:
multiply(_a, _b) Multiply vector _a with _b, in the form
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns:
divide(_a, _b) Divide vector _a with _b, in the form
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns:
negate(_a) Negative of vector _a, in the form
Parameters:
_a : vector in the form of a array .
Returns:
perp(_a) Perpendicular Vector of _a.
Parameters:
_a : vector in the form of a array .
Returns:
vfloor(_a) Compute the floor of argument vector _a.
Parameters:
_a : vector in the form of a array .
Returns:
fractional(_a) Compute the fractional part of the elements from vector _a.
Parameters:
_a : vector in the form of a array .
Returns:
vsin(_a) Compute the sine of argument vector _a.
Parameters:
_a : vector in the form of a array .
Returns:
equals(_a, _b) Compares two vectors
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: boolean value representing the equality.
dot(_a, _b) Dot product of 2 vectors, in the form
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: float
cross_product(_a, _b) cross product of 2 vectors, in the form
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: float
scale(_a, _scalar) Multiply a vector by a scalar.
Parameters:
_a : vector in the form of a array .
_scalar : value to multiply vector elements by.
Returns: float vector
normalize(_a) Vector _a normalized with a magnitude of 1, in the form.
Parameters:
_a : vector in the form of a array .
Returns: float vector
rescale(_a) Rescale a vector to a new Magnitude.
Parameters:
_a : vector in the form of a array .
Returns:
rotate(_a, _radians) Rotates vector _a by angle value
Parameters:
_a : vector in the form of a array .
_radians : Angle value.
Returns:
rotate_degree(_a, _degree) Rotates vector _a by angle value
Parameters:
_a : vector in the form of a array .
_degree : Angle value.
Returns:
rotate_around(_center, _target, _degree) Rotates vector _target around _origin by angle value
Parameters:
_center : vector in the form of a array .
_target : vector in the form of a array .
_degree : Angle value.
Returns:
vceil(_a, _digits) Ceils vector _a
Parameters:
_a : vector in the form of a array .
_digits : digits to use as ceiling.
Returns:
vpow(_a) Raise both vector elements by a exponent.
Parameters:
_a : vector in the form of a array .
Returns:
distance(_a, _b) vector distance between 2 vectors.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: float, distance.
project(_a, _axis) Project a vector onto another.
Parameters:
_a : vector in the form of a array .
_axis : float vector2
Returns: float vector
projectN(_a, _axis) Project a vector onto a vector of unit length.
Parameters:
_a : vector in the form of a array .
_axis : vector in the form of a array .
Returns: float vector
reflect(_a, _b) Reflect a vector on another.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: float vector
reflectN(_a, _b) Reflect a vector to a arbitrary axis.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: float vector
angle(_a) Angle in radians of a vector.
Parameters:
_a : vector in the form of a array .
Returns: float
angle_unsigned(_a, _b) unsigned degree angle between 0 and +180 by given two vectors.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: float
angle_signed(_a, _b) Signed degree angle between -180 and +180 by given two vectors.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: float
angle_360(_a, _b) Degree angle between 0 and 360 by given two vectors
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
Returns: float
clamp(_a, _vmin, _vmax) Restricts a vector between a min and max value.
Parameters:
_a : vector in the form of a array .
_vmin : vector in the form of a array .
_vmax : vector in the form of a array .
Returns: float vector
lerp(_a, _b, _rate_of_move) Linearly interpolates between vectors a and b by _rate_of_move.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
_rate_of_move : float value between (a:-infinity -> b:1.0), negative values will move away from b.
Returns: vector in the form of a array
herp(_a, _b, _rate_of_move) Hermite curve interpolation between vectors a and b by _rate_of_move.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
_rate_of_move : float value between (a-infinity -> b1.0), negative values will move away from b.
Returns: vector in the form of a array
area_triangle(_a, _b, _c) Find the area in a triangle of vectors.
Parameters:
_a : vector in the form of a array .
_b : vector in the form of a array .
_c : vector in the form of a array .
Returns: float
to_string(_a) Converts vector _a to a string format, in the form "(x, y)"
Parameters:
_a : vector in the form of a array .
Returns: string in "(x, y)" format
vrandom(_max) 2D random value
Parameters:
_max : float vector, vector upper bound
Returns: vector in the form of a array
noise(_a) 2D Noise based on Morgan McGuire @morgan3d
thebookofshaders.com
www.shadertoy.com
Parameters:
_a : vector in the form of a array .
Returns: vector in the form of a array
array_new(_size, _initial_vector) Prototype to initialize a array of vectors.
Parameters:
_size : size of the array.
_initial_vector : vector to be used as default value, in the form of array .
Returns: _vector_array complex Array in the form of a array
array_size(_id) number of vector elements in array.
Parameters:
_id : ID of the array.
Returns: int
array_get(_id, _index) Get the vector in a array, in the form of a array
Parameters:
_id : ID of the array.
_index : Index of the vector.
Returns: vector in the form of a array
array_set(_id, _index, _a) Sets the values vector in a array.
Parameters:
_id : ID of the array.
_index : Index of the vector.
_a : vector, in the form .
Returns: Void, updates array _id.
array_push(_id, _a) inserts the vector at the end of array.
Parameters:
_id : ID of the array.
_a : vector, in the form .
Returns: Void, updates array _id.
array_unshift(_id, _a) inserts the vector at the begining of array.
Parameters:
_id : ID of the array.
_a : vector, in the form .
Returns: Void, updates array _id.
array_pop(_id, _a) removes the last vector of array and returns it.
Parameters:
_id : ID of the array.
_a : vector, in the form .
Returns: vector2, updates array _id.
array_shift(_id, _a) removes the first vector of array and returns it.
Parameters:
_id : ID of the array.
_a : vector, in the form .
Returns: vector2, updates array _id.
array_sum(_id) Total sum of all vectors.
Parameters:
_id : ID of the array.
Returns: vector in the form of a array
array_center(_id) Finds the vector center of the array.
Parameters:
_id : ID of the array.
Returns: vector in the form of a array
array_rotate_points(_id) Rotate Array vectors around origin vector by a angle.
Parameters:
_id : ID of the array.
Returns: rotated points array.
array_scale_points(_id) Scale Array vectors based on a origin vector perspective.
Parameters:
_id : ID of the array.
Returns: rotated points array.
array_tostring(_id, _separator) Reads a array of vectors into a string, of the form " ""
Parameters:
_id : ID of the array.
_separator : string separator for cell splitting.
Returns: string Translated complex array into string.
line_new(_a, _b) 2 vector line in the form.
Parameters:
_a : vector, in the form .
_b : vector, in the form .
Returns:
line_get_a(_line) Start vector of a line.
Parameters:
_line : vector4, in the form .
Returns: float vector2
line_get_b(_line) End vector of a line.
Parameters:
_line : vector4, in the form .
Returns: float vector2
line_intersect(_line1, _line2) Find the intersection vector of 2 lines.
Parameters:
_line1 : line of 2 vectors in the form of a array .
_line2 : line of 2 vectors in the form of a array .
Returns: vector in the form of a array .
draw_line(_line, _xloc, _extend, _color, _style, _width) Draws a line using line prototype.
Parameters:
_line : vector4, in the form .
_xloc : string
_extend : string
_color : color
_style : string
_width : int
Returns: draw line object
draw_triangle(_v1, _v2, _v3, _xloc, _color, _style, _width) Draws a triangle using line prototype.
Parameters:
_v1 : vector4, in the form .
_v2 : vector4, in the form .
_v3 : vector4, in the form .
_xloc : string
_color : color
_style : string
_width : int
Returns: tuple with 3 line objects.
draw_rect(_v1, _size, _angle, _xloc, _color, _style, _width) Draws a square using vector2 line prototype.
Parameters:
_v1 : vector4, in the form .
_size : float
_angle : float
_xloc : string
_color : color
_style : string
_width : int
Returns: tuple with 3 line objects.
SignalProcessingClusteringKMeansLibrary "SignalProcessingClusteringKMeans"
K-Means Clustering Method.
nearest(point_x, point_y, centers_x, centers_y) finds the nearest center to a point and returns its distance and center index.
Parameters:
point_x : float, x coordinate of point.
point_y : float, y coordinate of point.
centers_x : float array, x coordinates of cluster centers.
centers_y : float array, y coordinates of cluster centers.
@ returns tuple of int, float.
bisection_search(samples, value) Bissection Search
Parameters:
samples : float array, weights to compare.
value : float array, weights to compare.
Returns: int.
label_points(points_x, points_y, centers_x, centers_y) labels each point index with cluster index and distance.
Parameters:
points_x : float array, x coordinates of points.
points_y : float array, y coordinates of points.
centers_x : float array, x coordinates of points.
centers_y : float array, y coordinates of points.
Returns: tuple with int array, float array.
kpp(points_x, points_y, n_clusters) K-Means++ Clustering adapted from Andy Allinger.
Parameters:
points_x : float array, x coordinates of the points.
points_y : float array, y coordinates of the points.
n_clusters : int, number of clusters.
Returns: tuple with 2 arrays, float array, int array.
FunctionDatestringLibrary "FunctionDatestring"
Methods to stringify date/time, altho there is already builtin support for it.
datetime(unixtime) a stringified date stamp at specified unix time.
Parameters:
unixtime : int unix timestamp.
Returns: string
date_(unixtime) a stringified date stamp at specified unix time.
Parameters:
unixtime : int unix timestamp.
Returns: string
time_(unixtime) a stringified date stamp at specified unix time.
Parameters:
unixtime : int unix timestamp.
Returns: string
HarmonicPatternLibrary "HarmonicPattern"
Functions to detect/check harmonic patterns from provided values.
line_price_rate(point_c, point_b, point_a) Compute the price rate of the line AB divided by the the line BC
Parameters:
point_c : float, the price at point C.
point_b : float, the price at point B.
point_a : float, the price at point A.
Returns: float
line_time_rate(_c, _b, _a) Compute the time rate of the line AB divided by the the line BC
Parameters:
_c : float, the time or bar_index at point C.
_b : float, the time or bar_index at point B.
_a : float, the time or bar_index at point A.
Returns: float
is_inrange(value, min, max) Check if value is within min/max range of tolerance.
Parameters:
value : float, value to check tolerance.
min : float, minimum value in range of tolerance.
max : float, maximum value in range of tolerance.
Returns: bool
isHarmonicTriangle(rate_cba, margin_of_error) Check if the rate(s) correspond to pattern ("Harmonic Triangle").
Parameters:
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
is2Tap(rate_cba, margin_of_error) Check if the rate(s) correspond to pattern ("2Tap", 'Double Top / Bottom').
Parameters:
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
is3Tap(rate_edc, rate_cba, margin_of_error) Check if the rate(s) correspond to pattern ("3Tap", "Triple Top / Bottom").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
is4Tap(rate_gfe, rate_edc, rate_cba, margin_of_error) Check if the rate(s) correspond to pattern ("4Tap", "Quadruple Top / Bottom").
Parameters:
rate_gfe : float, percent rate of the triangle GFE. expects a negative rate.
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isABCD(rate_cba, rate_dcb, margin_of_error) Check if the rate(s) correspond to pattern ("AB=CD").
Parameters:
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isBat(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Bat").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isButterfly(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Butterfly").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isGartley(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Gartley").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isCrab(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Crab").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isShark(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Shark").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
is5o(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("5o").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isWolfe(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Wolfe").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
is3Driver(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("3 Driver").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isConTria(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Contracting Triangle").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isExpTria(rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Expanding Triangle").
Parameters:
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
isHnS(rate_fed, rate_feb, rate_edc, rate_dcb, rate_cba, rate_eda, margin_of_error) Check if the rate(s) correspond to pattern ("Head and Shoulders").
Parameters:
rate_fed : float, percent rate of the triangle FED. expects a negative rate.
rate_feb : float, percent rate of the triangle FEB. expects a negative rate.
rate_edc : float, percent rate of the triangle EDC. expects a negative rate.
rate_dcb : float, percent rate of the triangle DCB. expects a negative rate.
rate_cba : float, percent rate of the triangle CBA. expects a negative rate.
rate_eda : float, percent rate of the triangle EDA. expects a negative rate.
margin_of_error : float, percent rate of expected error margin, default 0.05(5%).
Returns: bool
DebugConsoleLibrary "DebugConsole"
Methods for debuging/output into a table, console like style.
init(size) initiate property variables.
Parameters:
size : int, console line size.
Returns: tuple, table and string array.
queue(console_id, new_line) Regular Queue, will be called once every bar its called.
Parameters:
console_id : string array, console configuration array.
new_line : string, with contents for new line.
Returns: void.
queue_one(console_id, new_line) Queue only one time, will not repeat itself.
Parameters:
console_id : string array, console configuration array.
new_line : string, with contents for new line.
Returns: void.
update(table_id, console_id) Update method for the console screen.
Parameters:
table_id : table, table to update console text.
console_id : string array, console configuration array.
Returns: void.
SupportResitanceAndTrendLibrary "SupportResitanceAndTrend"
Contains utilities for finding key levels of support, resistance and direction of trend.
superTrendPlus(multiple, h, l, atr, closeBars) A more flexible version of SuperTrend that allows for supplying the series used and sensitivity adjustment by confirming close bars.
Parameters:
multiple : The multiple to apply to the average true range.
h : The high values.
l : The low values.
atr : The average true range values.
closeBars : The number of bars to confirm a change in trend.
Returns:
superTrend(multiple, period, mode, closeBars) superTrendPlus with simplified parameters.
Parameters:
multiple : The multiple to apply to the average true range.
period : The number of bars to measure.
mode : The type of moving average to use with the true range.
closeBars : The number of bars to confirm a change in trend.
Returns:
stochSR() Identifies support and resistance levels by when a stochastic RSI reverses. Returns:
MovingAveragesLibrary "MovingAverages"
Contains utilities for generating moving average values including getting a moving average by name and a function for generating a Volume-Adjusted WMA.
vawma(len, src, volumeDefault) VAWMA = VWMA and WMA combined. Simply put, this attempts to determine the average price per share over time weighted heavier for recent values. Uses a triangular algorithm to taper off values in the past (same as WMA does).
Parameters:
len : The number of bars to measure with.
src : The series to measure from. Default is 'hlc3'.
volumeDefault : The default value to use when a chart has no (N/A) volume.
Returns: The volume adjusted triangular weighted moving average of the series.
getMA(mode, len, src) Generates a moving average based upon a 'mode'.
Parameters:
mode : The type of moving average to generate. Values allowed are: SMA, EMA, WMA, VWMA and VAWMA.
len : The number of bars to measure with.
src : The series to measure from. Default is 'close'.
Returns: The volume adjusted triangular weighted moving average of the series.