ZigzagMethodsLibrary "ZigzagMethods"
Object oriented implementation of Zigzag methods. Please refer to ZigzagTypes library for User defined types used in this library
tostring(this, sortKeys, sortOrder, includeKeys)
Converts ZigzagTypes/Pivot object to string representation
Parameters:
this : ZigzagTypes/Pivot
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of ZigzagTypes/Pivot
tostring(this, sortKeys, sortOrder, includeKeys)
Converts Array of Pivot objects to string representation
Parameters:
this : Pivot object array
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of Pivot object array
tostring(this)
Converts ZigzagFlags object to string representation
Parameters:
this : ZigzagFlags object
Returns: string representation of ZigzagFlags
tostring(this, sortKeys, sortOrder, includeKeys)
Converts ZigzagTypes/Zigzag object to string representation
Parameters:
this : ZigzagTypes/Zigzagobject
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of ZigzagTypes/Zigzag
calculate(this, ohlc, indicators, indicatorNames)
Calculate zigzag based on input values and indicator values
Parameters:
this : Zigzag object
ohlc : Array containing OHLC values. Can also have custom values for which zigzag to be calculated
indicators : Array of indicator values
indicatorNames : Array of indicator names for which values are present. Size of indicators array should be equal to that of indicatorNames
Returns: current Zigzag object
calculate(this)
Calculate zigzag based on properties embedded within Zigzag object
Parameters:
this : Zigzag object
Returns: current Zigzag object
nextlevel(this)
Calculate Next Level Zigzag based on the current calculated zigzag object
Parameters:
this : Zigzag object
Returns: Next Level Zigzag object
clear(this)
Clears zigzag drawings array
Parameters:
this : array
Returns: void
drawfresh(this)
draws fresh zigzag based on properties embedded in ZigzagDrawing object
Parameters:
this : ZigzagDrawing object
Returns: ZigzagDrawing object
drawcontinuous(this)
draws zigzag based on the zigzagmatrix input
Parameters:
this : ZigzagDrawing object
Returns:
Indicators and strategies
ZigzagTypesLibrary "ZigzagTypes"
Zigzag related user defined types. Depends on DrawingTypes library for basic types
Indicator
Indicator is collection of indicator values applied on high, low and close
Fields:
indicatorHigh : Indicator Value applied on High
indicatorLow : Indicator Value applied on Low
PivotCandle
PivotCandle represents data of the candle which forms either pivot High or pivot low or both
Fields:
_high : High price of candle forming the pivot
_low : Low price of candle forming the pivot
length : Pivot length
pHighBar : represents number of bar back the pivot High occurred.
pLowBar : represents number of bar back the pivot Low occurred.
pHigh : Pivot High Price
pLow : Pivot Low Price
indicators : Array of Indicators - allows to add multiple
Pivot
Pivot refers to zigzag pivot. Each pivot can contain various data
Fields:
point : pivot point coordinates
dir : direction of the pivot. Valid values are 1, -1, 2, -2
level : is used for multi level zigzags. For single level, it will always be 0
ratio : Price Ratio based on previous two pivots
indicatorNames : Names of the indicators applied on zigzag
indicatorValues : Values of the indicators applied on zigzag
indicatorRatios : Ratios of the indicators applied on zigzag based on previous 2 pivots
ZigzagFlags
Flags required for drawing zigzag. Only used internally in zigzag calculation. Should not set the values explicitly
Fields:
newPivot : true if the calculation resulted in new pivot
doublePivot : true if the calculation resulted in two pivots on same bar
updateLastPivot : true if new pivot calculated replaces the old one.
Zigzag
Zigzag object which contains whole zigzag calculation parameters and pivots
Fields:
length : Zigzag length. Default value is 5
numberOfPivots : max number of pivots to hold in the calculation. Default value is 20
offset : Bar offset to be considered for calculation of zigzag. Default is 0 - which means calculation is done based on the latest bar.
level : Zigzag calculation level - used in multi level recursive zigzags
zigzagPivots : array which holds the last n pivots calculated.
flags : ZigzagFlags object which is required for continuous drawing of zigzag lines.
ZigzagObject
Zigzag Drawing Object
Fields:
zigzagLine : Line joining two pivots
zigzagLabel : Label which can be used for drawing the values, ratios, directions etc.
ZigzagProperties
Object which holds properties of zigzag drawing. To be used along with ZigzagDrawing
Fields:
lineColor : Zigzag line color. Default is color.blue
lineWidth : Zigzag line width. Default is 1
lineStyle : Zigzag line style. Default is line.style_solid.
showLabel : If set, the drawing will show labels on each pivot. Default is false
textColor : Text color of the labels. Only applicable if showLabel is set to true.
maxObjects : Max number of zigzag lines to display. Default is 300
xloc : Time/Bar reference to be used for zigzag drawing. Default is Time - xloc.bar_time.
ZigzagDrawing
Object which holds complete zigzag drawing objects and properties.
Fields:
properties : ZigzagProperties object which is used for setting the display styles of zigzag
drawings : array which contains lines and labels of zigzag drawing.
zigzag : Zigzag object which holds the calculations.
DrawingMethodsLibrary "DrawingMethods"
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/Point object to string representation
Parameters:
this : DrawingTypes/Point object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/Point
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/LineProperties object to string representation
Parameters:
this : DrawingTypes/LineProperties object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/LineProperties
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/Line object to string representation
Parameters:
this : DrawingTypes/Line object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/Line
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/LabelProperties object to string representation
Parameters:
this : DrawingTypes/LabelProperties object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/LabelProperties
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/Label object to string representation
Parameters:
this : DrawingTypes/Label object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/Label
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/Linefill object to string representation
Parameters:
this : DrawingTypes/Linefill object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/Linefill
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/BoxProperties object to string representation
Parameters:
this : DrawingTypes/BoxProperties object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/BoxProperties
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/BoxText object to string representation
Parameters:
this : DrawingTypes/BoxText object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/BoxText
tostring(this, sortKeys, sortOrder, includeKeys)
Converts DrawingTypes/Box object to string representation
Parameters:
this : DrawingTypes/Box object
sortKeys : If set to true, string output is sorted by keys.
sortOrder : Applicable only if sortKeys is set to true. Positive number will sort them in ascending order whreas negative numer will sort them in descending order. Passing 0 will not sort the keys
includeKeys : Array of string containing selective keys. Optional parmaeter. If not provided, all the keys are considered
Returns: string representation of DrawingTypes/Box
delete(this)
Deletes line from DrawingTypes/Line object
Parameters:
this : DrawingTypes/Line object
Returns: Line object deleted
delete(this)
Deletes label from DrawingTypes/Label object
Parameters:
this : DrawingTypes/Label object
Returns: Label object deleted
delete(this)
Deletes Linefill from DrawingTypes/Linefill object
Parameters:
this : DrawingTypes/Linefill object
Returns: Linefill object deleted
delete(this)
Deletes box from DrawingTypes/Box object
Parameters:
this : DrawingTypes/Box object
Returns: DrawingTypes/Box object deleted
delete(this)
Deletes lines from array of DrawingTypes/Line objects
Parameters:
this : Array of DrawingTypes/Line objects
Returns: Array of DrawingTypes/Line objects
delete(this)
Deletes labels from array of DrawingTypes/Label objects
Parameters:
this : Array of DrawingTypes/Label objects
Returns: Array of DrawingTypes/Label objects
delete(this)
Deletes linefill from array of DrawingTypes/Linefill objects
Parameters:
this : Array of DrawingTypes/Linefill objects
Returns: Array of DrawingTypes/Linefill objects
delete(this)
Deletes boxes from array of DrawingTypes/Box objects
Parameters:
this : Array of DrawingTypes/Box objects
Returns: Array of DrawingTypes/Box objects
clear(this)
clear items from array of DrawingTypes/Line while deleting underlying objects
Parameters:
this : array
Returns: void
clear(this)
clear items from array of DrawingTypes/Label while deleting underlying objects
Parameters:
this : array
Returns: void
clear(this)
clear items from array of DrawingTypes/Linefill while deleting underlying objects
Parameters:
this : array
Returns: void
clear(this)
clear items from array of DrawingTypes/Box while deleting underlying objects
Parameters:
this : array
Returns: void
draw(this)
Creates line from DrawingTypes/Line object
Parameters:
this : DrawingTypes/Line object
Returns: line created from DrawingTypes/Line object
draw(this)
Creates lines from array of DrawingTypes/Line objects
Parameters:
this : Array of DrawingTypes/Line objects
Returns: Array of DrawingTypes/Line objects
draw(this)
Creates label from DrawingTypes/Label object
Parameters:
this : DrawingTypes/Label object
Returns: label created from DrawingTypes/Label object
draw(this)
Creates labels from array of DrawingTypes/Label objects
Parameters:
this : Array of DrawingTypes/Label objects
Returns: Array of DrawingTypes/Label objects
draw(this)
Creates linefill object from DrawingTypes/Linefill
Parameters:
this : DrawingTypes/Linefill objects
Returns: linefill object created
draw(this)
Creates linefill objects from array of DrawingTypes/Linefill objects
Parameters:
this : Array of DrawingTypes/Linefill objects
Returns: Array of DrawingTypes/Linefill used for creating linefills
draw(this)
Creates box from DrawingTypes/Box object
Parameters:
this : DrawingTypes/Box object
Returns: box created from DrawingTypes/Box object
draw(this)
Creates labels from array of DrawingTypes/Label objects
Parameters:
this : Array of DrawingTypes/Label objects
Returns: Array of DrawingTypes/Label objects
createLabel(this, lblText, tooltip, properties)
Creates DrawingTypes/Label object from DrawingTypes/Point
Parameters:
this : DrawingTypes/Point object
lblText : Label text
tooltip : Tooltip text. Default is na
properties : DrawingTypes/LabelProperties object. Default is na - meaning default values are used.
Returns: DrawingTypes/Label object
createLine(this, other, properties)
Creates DrawingTypes/Line object from one DrawingTypes/Point to other
Parameters:
this : First DrawingTypes/Point object
other : Second DrawingTypes/Point object
properties : DrawingTypes/LineProperties object. Default set to na - meaning default values are used.
Returns: DrawingTypes/Line object
createLinefill(this, other, fillColor, transparency)
Creates DrawingTypes/Linefill object from DrawingTypes/Line object to other DrawingTypes/Line object
Parameters:
this : First DrawingTypes/Line object
other : Other DrawingTypes/Line object
fillColor : fill color of linefill. Default is color.blue
transparency : fill transparency for linefill. Default is 80
Returns: Array of DrawingTypes/Linefill object
createBox(this, other, properties, textProperties)
Creates DrawingTypes/Box object from one DrawingTypes/Point to other
Parameters:
this : First DrawingTypes/Point object
other : Second DrawingTypes/Point object
properties : DrawingTypes/BoxProperties object. Default set to na - meaning default values are used.
textProperties : DrawingTypes/BoxText object. Default is na - meaning no text will be drawn
Returns: DrawingTypes/Box object
createBox(this, properties, textProperties)
Creates DrawingTypes/Box object from DrawingTypes/Line as diagonal line
Parameters:
this : Diagonal DrawingTypes/PoLineint object
properties : DrawingTypes/BoxProperties object. Default set to na - meaning default values are used.
textProperties : DrawingTypes/BoxText object. Default is na - meaning no text will be drawn
Returns: DrawingTypes/Box object
DrawingTypesLibrary "DrawingTypes"
User Defined Types for basic drawing structure. Other types and methods will be built on these.
Point
Point refers to point on chart
Fields:
price : pivot price
bar : pivot bar
bartime : pivot bar time
LineProperties
Properties of line object
Fields:
xloc : X Reference - can be either xloc.bar_index or xloc.bar_time. Default is xloc.bar_index
extend : Property which sets line to extend towards either right or left or both. Valid values are extend.right, extend.left, extend.both, extend.none. Default is extend.none
color : Line color
style : Line style, valid values are line.style_solid, line.style_dashed, line.style_dotted, line.style_arrow_left, line.style_arrow_right, line.style_arrow_both. Default is line.style_solid
width : Line width. Default is 1
Line
Line object created from points
Fields:
start : Starting point of the line
end : Ending point of the line
properties : LineProperties object which defines the style of line
object : Derived line object
LabelProperties
Properties of label object
Fields:
xloc : X Reference - can be either xloc.bar_index or xloc.bar_time. Default is xloc.bar_index
yloc : Y reference - can be yloc.price, yloc.abovebar, yloc.belowbar. Default is yloc.price
color : Label fill color
style : Label style as defined in www.tradingview.com Default is label.style_none
textcolor : text color. Default is color.black
size : Label text size. Default is size.normal. Other values are size.auto, size.tiny, size.small, size.normal, size.large, size.huge
textalign : Label text alignment. Default if text.align_center. Other allowed values - text.align_right, text.align_left, text.align_top, text.align_bottom
text_font_family : The font family of the text. Default value is font.family_default. Other available option is font.family_monospace
Label
Label object
Fields:
point : Point where label is drawn
lblText : label text
tooltip : Tooltip text. Default is na
properties : LabelProperties object
object : Pine label object
Linefill
Linefill object
Fields:
line1 : First line to create linefill
line2 : Second line to create linefill
fillColor : Fill color
transparency : Fill transparency range from 0 to 100
object : linefill object created from wrapper
BoxProperties
BoxProperties object
Fields:
border_color : Box border color. Default is color.blue
bgcolor : box background color
border_width : Box border width. Default is 1
border_style : Box border style. Default is line.style_solid
extend : Extend property of box. default is extend.none
xloc : defines if drawing needs to be done based on bar index or time. default is xloc.bar_index
BoxText
Box Text properties.
Fields:
boxText : Text to be printed on the box
text_size : Text size. Default is size.auto
text_color : Box text color. Default is color.yellow.
text_halign : horizontal align style - default is text.align_center
text_valign : vertical align style - default is text.align_center
text_wrap : text wrap style - default is text.wrap_auto
text_font_family : Text font. Default is
Box
Box object
Fields:
p1 : Diagonal point one
p2 : Diagonal point two
properties : Box properties
textProperties : Box text properties
object : Box object created
Wave Generator Library (WGL)Library "WaveGenerator"
Wave Generator Library
max(source)
max
Parameters:
source : is the input to take the maximum.
Returns: foat
min(source)
min
Parameters:
source : is the input to take the minimum.
Returns: foat
min_max(src, height)
min_max
Parameters:
src : is the input for the min/max
height
Returns: float
sine_wave(_wave_height, _wave_duration, _phase_shift, _phase_shift_2)
sine_wave
Parameters:
_wave_height : Maximum output level
_wave_duration : Wave length
_phase_shift : Number of harmonics
_phase_shift_2
Returns: float
triangle_wave(_wave_height, _wave_duration, _num_harmonics, _phase_shift)
triangle_wave
Parameters:
_wave_height : Maximum output level
_wave_duration : Wave length
_num_harmonics : Number of harmonics
_phase_shift : Phase shift
Returns: float
saw_wave(_wave_height, _wave_duration, _num_harmonics, _phase_shift)
saw_wave
Parameters:
_wave_height : Maximum output level
_wave_duration : Wave length
_num_harmonics : Number of harmonics
_phase_shift : Phase shift
Returns: float
ramp_saw_wave(_wave_height, _wave_duration, _num_harmonics, _phase_shift)
ramp_saw_wave
Parameters:
_wave_height : Maximum output level
_wave_duration : Wave length
_num_harmonics : Number of harmonics
_phase_shift : Phase shift
Returns: float
square_wave(_wave_height, _wave_duration, _num_harmonics, _phase_shift)
square_wave
Parameters:
_wave_height : Maximum output level
_wave_duration : Wave length
_num_harmonics : Number of harmonics
_phase_shift : Phase shift
Returns: float
wave_select(style, _wave_height, _wave_duration, _num_harmonics, _phase_shift)
wave_select
@peram style Select the style of wave. "Sine", "Triangle", "Saw", "Ramp Saw", "Square"
Parameters:
style
_wave_height : Maximum output level
_wave_duration : Wave length
_num_harmonics : Number of harmonics
_phase_shift : Phase shift
Returns: float
CommonTypesMathLibrary "CommonTypesMath"
Provides a common library source for common types of useful mathematical structures.
Includes: `complex, Vector2, Vector3, Vector4, Quaternion, Segment2, Segment3, Pole, Plane, M32, M44`
complex
Representation of a Complex Number, a complex number `z` is a number in the form `z = x + yi`,
Fields:
re : Real part of the complex number.
im : Imaginary part of the complex number.
Vector2
Representation of a two dimentional vector with components `(x:float,y:float)`.
Fields:
x : Coordinate `x` of the vector.
y : Coordinate `y` of the vector.
Vector3
Representation of a three dimentional vector with components `(x:float,y:float,z:float)`.
Fields:
x : Coordinate `x` of the vector.
y : Coordinate `y` of the vector.
z : Coordinate `z` of the vector.
Vector4
Representation of a four dimentional vector with components `(x:float,y:float,z:float,w:float)`.
Fields:
x : Coordinate `x` of the vector.
y : Coordinate `y` of the vector.
z : Coordinate `z` of the vector.
w : Coordinate `w` of the vector.
Quaternion
Representation of a four dimentional vector with components `(x:float,y:float,z:float,w:float)`.
Fields:
x : Coordinate `x` of the vector.
y : Coordinate `y` of the vector.
z : Coordinate `z` of the vector.
w : Coordinate `w` of the vector, specifies the rotation component.
Segment2
Representation of a line in two dimentional space.
Fields:
origin : Origin coordinates.
target : Target coordinates.
Segment3
Representation of a line in three dimentional space.
Fields:
origin : Origin coordinates.
target : Target coordinates.
Pole
Representation of polar coordinates `(radius:float,angle:float)`.
Fields:
radius : Radius of the pole.
angle : Angle in radians of the pole.
Plane
Representation of a 3D plane.
Fields:
normal : Normal vector of the plane.
distance : Distance of the plane along its normal from the origin.
M32
Representation of a 3x2 matrix.
Fields:
m11 : First element of the first row.
m12 : Second element of the first row.
m21 : First element of the second row.
m22 : Second element of the second row.
m31 : First element of the third row.
m32 : Second element of the third row.
M44
Representation of a 4x4 matrix.
Fields:
m11 : First element of the first row.
m12 : Second element of the first row.
m13 : Third element of the first row.
m14 : fourth element of the first row.
m21 : First element of the second row.
m22 : Second element of the second row.
m23 : Third element of the second row.
m24 : fourth element of the second row.
m31 : First element of the third row.
m32 : Second element of the third row.
m33 : Third element of the third row.
m34 : fourth element of the third row.
m41 : First element of the fourth row.
m42 : Second element of the fourth row.
m43 : Third element of the fourth row.
m44 : fourth element of the fourth row.
Sub-Super Script and Roman numerals LibraryLibrary "Sub_Super_Script_and_RomanNumerals_Library"
Library to transform numbers into Roman numerals / Super-Sub script / check if value is alpha or number
isnumber(input)
check to see if value is a number
Parameters:
input : (string/float/int) value to check
Returns: (na) if value is NOT a number and input (string/float/int) if value is a number
isalpha(input)
check a string if it is alpha(doesnt contain numbers)
Parameters:
input
Returns: (string) if string input does NOT contain numbers, return (na) if input string contains numbers
super(num)
convert a string's numbers from normal print to super-script
Parameters:
num : (string/int/float) input value to transform
Returns: string of input with numbers converted to super-script
sub(num)
convert a string's numbers from normal print to sub-script
Parameters:
num : (string/int/float) input value to transform
Returns: string of input with numbers converted to sub-script
roman(num, trunc)
convert a string of numbers, float, or int
Parameters:
num : (string) input number to transform
trunc : (bool | false) true to truncate float value, false to show roman numerals with decimals (XX.VI)
Returns: string of roman numerals representing the input (num)
FrizLabz_Time_Utility_MethodsLibrary "FrizLabz_Time_Utility_Methods"
Some time to index and index to time helper methods made them for another library thought I would try to make
them as methods
UTC_helper(utc)
UTC helper function this adds the + to the positive utc times, add "UTC" to the string
and can be used in the timezone arg of for format_time()
Parameters:
utc : (int) | +/- utc offset
Returns: string | string to be added to the timezone paramater for utc timezone usage
bar_time(bar_amount)
from a time to index
Parameters:
bar_amount : (int) | default - 1)
Returns: int bar_time
time_to_index(_time)
from time to bar_index
Parameters:
_time : (int)
Returns: int time_to_index | bar_index that corresponds to time provided
time_to_bars_back(_time)
from a time quanity to bar quanity for use with .
Parameters:
_time : (int)
Returns: int bars_back | yeilds the amount of bars from current bar to reach _time provided
bars_back_to_time(bars_back)
from bars_back to time
Parameters:
bars_back
Returns: int | using same logic as this will return the
time of the bar = to the bar that corresponds to bars_back
index_time(index)
bar_index to UNIX time
Parameters:
index : (int)
Returns: int time | time in unix that corrresponds to the bar_index
to_utc(time_or_index, timezone, format)
method to use with a time or bar_index variable that will detect if it is an index or unix time
and convert it to a printable string
Parameters:
time_or_index : (int) required) | time in unix or bar_index
timezone : (int) required) | utc offset to be appled to output
format : (string) | default - "yyyy-MM-dd'T'HH:mm:ssZ") | the format for the time, provided string is
default one from str.format_time()
Returns: string | time formatted string
GET(line)
Gets the location paramaters of a Line
Parameters:
line : (line)
Returns: tuple
GET(box)
Gets the location paramaters of a Box
Parameters:
box : (box)
Returns: tuple
GET(label)
Gets the location paramaters and text of a Label
Parameters:
label : (label)
Returns: tuple
GET(linefill)
Gets line 1 and 2 from a Linefill
Parameters:
linefill : (linefill)
Returns: tuple
Format(line, timezone)
converts Unix time in time or index params to formatted time
and returns a tuple of the params as string with the time/index params formatted
Parameters:
line : (line) | required
timezone : (int) | default - na
Returns: tuple
Line(x1, y1, x2, y2, extend, color, style, width)
similar to line.new() with the exception
of not needing to include y2 for a flat line, y1 defaults to close,
and it doesnt require xloc.bar_time or xloc.bar_index, if no x1
Parameters:
x1 : (int) default - time
y1 : (float) default - close
x2 : (int) default - last_bar_time/last_bar_index | not required for line that ends on current bar
y2 : (float) default - y1 | not required for flat line
extend : (string) default - extend.none | extend.left, extend.right, extend.both
color : (color) default - chart.fg_color
style : (string) default - line.style_solid | line.style_dotted, line.style_dashed,
line.style_arrow_both, line.style_arrow_left, line.style_arrow_right
width
Returns: line
Box(left, top, right, bottom, extend, border_color, bgcolor, text_color, border_width, border_style, txt, text_halign, text_valign, text_size, text_wrap)
similar to box.new() but only requires top and bottom to create box,
auto detects if it is bar_index or time used in the (left) arg. xloc.bar_time and xloc.bar_index are not used
args are ordered by purpose | position -> colors -> styling -> text options
Parameters:
left : (int) default - time
top : (float) required
right : (int) default - last_bar_time/last_bar_index | will default to current bar index or time
depending on (left) arg
bottom : (float) required
extend : (string) default - extend.none | extend.left, extend.right, extend.both
border_color : (color) default - chart.fg_color
bgcolor : (color) default - color.new(chart.fg_color,75)
text_color : (color) default - chart.bg_color
border_width : (int) default - 1
border_style : (string) default - line.style_solid | line.style_dotted, line.style_dashed,
txt : (string) default - ''
text_halign : (string) default - text.align_center | text.align_left, text.align_right
text_valign : (string) default - text.align_center | text.align_top, text.align_bottom
text_size : (string) default - size.normal | size.tiny, size.small, size.large, size.huge
text_wrap : (string) default - text.wrap_auto | text.wrap_none
Returns: box
Label(x, y, txt, yloc, color, textcolor, style, size, textalign, text_font_family, tooltip)
similar to label.new() but only requires no args to create label,
auto detects if it is bar_index or time used in the (x) arg. xloc.bar_time and xloc.bar_index are not used
args are ordered by purpose | position -> colors -> styling -> text options
Parameters:
x : (int) default - time
y : (float) default - high or low | depending on bar direction
txt : (string) default - ''
yloc : (string) default - yloc.price | yloc.price, yloc.abovebar, yloc.belowbar
color : (color) default - chart.fg_color
textcolor : (color) default - chart.bg_color
style : (string) default - label.style_label_down | label.style_none
label.style_xcross,label.style_cross,label.style_triangleup,label.style_triangledown
label.style_flag, label.style_circle, label.style_arrowup, label.style_arrowdown,
label.style_label_up, label.style_label_down, label.style_label_left, label.style_label_right,
label.style_label_lower_left, label.style_label_lower_right, label.style_label_upper_left,
label.style_label_upper_right, label.style_label_center, label.style_square,
label.style_diamond
size : (string) default - size.normal | size.tiny, size.small, size.large, size.huge
textalign : (string) default - text.align_center | text.align_left, text.align_right
text_font_family : (string) default - font.family_default | font.family_monospace
tooltip : (string) default - na
Returns: label
PositionLibrary "Position"
Allows for simulating trades within an indicator.
newTrade(size, price, timestamp)
Creates a new trade object.
Parameters:
size : The size of the trade (number of shares or contracts).
price : The price at which the trade took place.
timestamp : The timestamp of the trade. Defaults to the current time.
Returns: A new trade object.
start(size, price, timestamp)
Starts a new position.
Parameters:
size : The size of the position (number of shares or contracts).
price : The price at which the position was started.
timestamp : The timestamp of the start of the position. Defaults to the current time.
Returns: A new position object.
trade(pos, size, price, timestamp)
Modifies an existing position.
Parameters:
pos : The position to be modified.
size : The size of the trade (number of shares or contracts).
price : The price at which the trade took place.
timestamp : The timestamp of the trade. Defaults to the current time.
Returns: The modified position object.
exit(pos, price, timestamp)
Closes a position by trading the entire position size at a given price and timestamp.
Parameters:
pos : The position being closed.
price : The price at which the position is being closed.
timestamp : The timestamp of the trade, defaults to the current time.
Returns: The updated position after the trade.
unrealized(pos, price)
Calculates the unrealized gain or loss for a given position and price.
Parameters:
pos : The position for which to calculate unrealized gain/loss.
price : The current market price.
Returns: The calculated unrealized gain or loss.
Trade
Represents a single trade.
Fields:
size : Size of the trade in units.
price : Price of the trade in currency.
value : Total value of the trade in currency units.
time : Timestamp of the trade.
Position
Represents a single position.
Fields:
size : Size of the position in units.
price : Average price of the position in currency.
value : Total value of the position in currency units.
start : Timestamp of the first trade that opened the position.
net : Realized gains and losses of the position in currency units.
history : Array of trades that make up the position.
Liquidation_linesLibrary "Liquidationline"
f_calculateLeverage(_leverage, _maintainance, _value, _direction)
Parameters:
_leverage
_maintainance
_value
_direction
f_liqline_update(_Liqui_Line, _killonlowhigh)
Parameters:
_Liqui_Line
_killonlowhigh
f_liqline_draw(_Liqui_Line, _priceorliq)
Parameters:
_Liqui_Line
_priceorliq
f_liqline_add(_Liqui_Line, linetoadd, _limit)
Parameters:
_Liqui_Line
linetoadd
_limit
Liquidationline
Fields:
creationtime
stoptime
price
leverage
maintainance
line_active
line_color
line_thickness
line_style
line_direction
line_finished
text_active
text_size
text_color
this library can draw typical liquidation lines, which can be called e.g. by indicator signals
You can see the default implementation in the lower part of the code, starting with RUNTIME
Don't forget to increase max lines to 500 in your script.
It can look like this screenshot here, with only minor changes to your executing script.
The base is the same
EventsLibrary "Events"
events()
Returns the list of dates supported by this library as a string array.
Returns: array : Names of events supported by this library
fomcMeetings()
Gets the FOMC Meeting Dates. The FOMC meets eight times a year to determine the course of monetary policy. The FOMC announces its decision on the federal funds rate at the conclusion of each meeting and also issues a statement that provides information on the economic outlook and the Committee's assessment of the risks to the outlook.
Returns: array : FOMC Meeting Dates as timestamps
fomcMinutes()
Gets the FOMC Meeting Minutes Dates. The FOMC Minutes are released three weeks after each FOMC meeting. The Minutes provide information on the Committee's deliberations and decisions at the meeting.
Returns: array : FOMC Meeting Minutes Dates as timestamps
ppiReleases()
Gets the Producer Price Index (PPI) Dates. The Producer Price Index (PPI) measures the average change over time in the selling prices received by domestic producers for their output. The PPI is a leading indicator of CPI, and CPI is a leading indicator of inflation.
Returns: array : PPI Dates as timestamps
cpiReleases()
Gets the Consumer Price Index (CPI) Rekease Dates. The Consumer Price Index (CPI) measures changes in the price level of a market basket of consumer goods and services purchased by households. The CPI is a leading indicator of inflation.
Returns: array : CPI Dates as timestamps
csiReleases()
Gets the CSI release dates. The Consumer Sentiment Index (CSI) is a survey of consumer attitudes about the economy and their personal finances. The CSI is a leading indicator of consumer spending.
Returns: array : CSI Dates as timestamps
cciReleases()
Gets the CCI release dates. The Conference Board's Consumer Confidence Index (CCI) is a survey of consumer attitudes about the economy and their personal finances. The CCI is a leading indicator of consumer spending.
Returns: array : CCI Dates as timestamps
nfpReleases()
Gets the NFP release dates. Nonfarm payrolls is an employment report released monthly by the Bureau of Labor Statistics (BLS) that measures the change in the number of employed people in the United States.
Returns: array : NFP Dates as timestamps
eciReleases()
Gets the ECI The Employment Cost Index (ECI) is a measure of the change in the cost of labor,
DistributionsLibrary "Distributions"
Library with price distribution zones calculation helpers.
Based on research from "Trading Systems and Methods, 5th Edition" by Perry J. Kaufman
getZones(h, l, c, window)
Returns price distribution zones based on HLC and for some period
Parameters:
h : high price
l : low price
c : close price
window : period to calculate distributions
Returns: tuple of 5 price zones in descent order, from highest to lowest
ColorsLibrary "Colors"
Helpers for color manipulations
opacify(oldColor, opacity)
Applies opacity to color
Parameters:
oldColor : color
opacity : opacity
Returns: color with opacity
PerformanceTableLibrary "PerformanceTable"
TODO: add library description here
This library was created as a library because adding a performance table to an existing strategy script made the strategy script lengthy and inconvenient to manage.
The monthly table script referenced @QuantNomad's code.
The performance table script referenced @myncrypto's code.
To use, copy and paste the code below at the bottom of the strategy script you are using, and the table for strategy performance will be displayed on a chart.
//------------Copy & Paste --------------------------------------//
import Cube_Lee/PerformanceTable/1 as PT
PT = input.bool(true, "Show Performance Table", tooltip = "전략의 성과를 우측상단에 테이블로 표시합니다.", group = "Performance Table")
MT = input.bool(true, "Show Monthly Table", tooltip = "전략의 월별 수익률을 우측하단에 테이블로 표시합니다.", group = "Performance Table")
if PT
PT.PerformanceTable()
if MT
PT.MonthlyTable()
//------------Copy & Paste---------------------------------------//
PerformanceTable()
MonthlyTable()
SH_LibraryLibrary "SH_Library"
events()
Returns the list of dates supported by this library as a string array.
Returns: array : Names of events supported by this library
fomcMeetings()
Gets the FOMC Meeting Dates. The FOMC meets eight times a year to determine the course of monetary policy. The FOMC announces its decision on the federal funds rate at the conclusion of each meeting and also issues a statement that provides information on the economic outlook and the Committee's assessment of the risks to the outlook.
Returns: array : FOMC Meeting Dates as timestamps
fomcMinutes()
Gets the FOMC Meeting Minutes Dates. The FOMC Minutes are released three weeks after each FOMC meeting. The Minutes provide information on the Committee's deliberations and decisions at the meeting.
Returns: array : FOMC Meeting Minutes Dates as timestamps
ppiReleases()
Gets the Producer Price Index (PPI) Dates. The Producer Price Index (PPI) measures the average change over time in the selling prices received by domestic producers for their output. The PPI is a leading indicator of CPI, and CPI is a leading indicator of inflation.
Returns: array : PPI Dates as timestamps
cpiReleases()
Gets the Consumer Price Index (CPI) Rekease Dates. The Consumer Price Index (CPI) measures changes in the price level of a market basket of consumer goods and services purchased by households. The CPI is a leading indicator of inflation.
Returns: array : CPI Dates as timestamps
csiReleases()
Gets the CSI release dates. The Consumer Sentiment Index (CSI) is a survey of consumer attitudes about the economy and their personal finances. The CSI is a leading indicator of consumer spending.
Returns: array : CSI Dates as timestamps
cciReleases()
Gets the CCI release dates. The Conference Board's Consumer Confidence Index (CCI) is a survey of consumer attitudes about the economy and their personal finances. The CCI is a leading indicator of consumer spending.
Returns: array : CCI Dates as timestamps
nfpReleases()
Gets the NFP release dates. Nonfarm payrolls is an employment report released monthly by the Bureau of Labor Statistics (BLS) that measures the change in the number of employed people in the United States.
Returns: array : NFP Dates as timestamps
eciReleases()
Gets the ECI The Employment Cost Index (ECI) is a measure of the change in the cost of labor,
Debugging_consoleRefer to notes for instruction
===================================================================
AntaresLibrary "Antares"
this library contains some utility functions that I use in my open source scripts including moving average helpers, candlstick helpers, money management, formatters, convertors, webhook integration, analysis, filters and drawing helpers
ma(type, length, source)
Wraps all ma functions
Parameters:
type : Either SMA or EMA or RMA or WMA or VWMA
length : Number of bars (length).
source : Series of values to process.
Returns: Moving average of `source` for `length` bars back by the of MA.
bb(ma, length, mult, source)
Overwrites `ta.bb` duo to limitations of simple int.float mult. Bollinger Bands. A Bollinger Band is a technical analysis tool defined by a set of lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of the security's price, but can be adjusted to user preferences.
Parameters:
ma : Either SMA or EMA or RMA or WMA or VWMA
length : Number of bars (length).
mult : Standard deviation factor.
source : Series of values to process.
Returns: Bollinger Bands.
atr(length, h, l, c)
Overwrites `ta.atr` duo to limitations of simple int length. Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close ), abs(low - close )).
Parameters:
length : Number of bars (length).
h : High price high price.
l : low price.
c : Close price close price.
Returns: Average true range.
rsi(length, source)
Overwrites `ta.rsi` duo to limitations of simple int length. Relative strength index. It is calculated using the `ta.rma()` of upward and downward changes of `source` over the last `length` bars.
Parameters:
length : Number of bars (length).
source : Series of values to process.
Returns: Relative strength index.
lowest(length, source, start)
Lowest value for a given number of bars back.
Parameters:
length : Number of bars (length).
source : Series of values to process.
start : Series number of bars that should be skipped before process.
Returns: Lowest value in the series.
highest(length, source, start)
Highest value for a given number of bars back.
Parameters:
length : Number of bars (length).
source : Series of values to process.
start : Series number of bars that should be skipped before process.
Returns: Highest value in the series.
atr_multiplier(rsi, atr_max_multiplier)
Dynamic atr multiplier calculated by RSI.
Parameters:
rsi : Relative strength index.
atr_max_multiplier : The maximum multiplier of atr
Returns: Dynamic multiplier of ATR
offset(atr, atr_multiplier)
Safe dynamic offset you need to use in your stoploss, stop buy/sell, etc.
Parameters:
atr : Average true range.
atr_multiplier : ATR multiplier got from `atr_multiplier(rsi, atr_max_multiplier)`
Returns: Dynamic offset
rsi_emotional(rsi, bottom, top)
Tells you if RSI is in emotional zone.
Parameters:
rsi : Relative Strength Index
bottom : The zone that below it market reacts emotionally
top : The zone that above it market reacts emotionally
Returns: false if RSI was between `bottom` and `top` otherwise true
rsi_signal(rsi, bottom, top)
Tells you if RSI is in good point to check your other strategy conditions.
Parameters:
rsi : Relative Strength Index
bottom : The zone that below it market reacts emotionally
top : The zone that above it market reacts emotionally
Returns: 1 if RSI crossed out 30, 50 or 70. -1 if RSI crossed under 70, 50, 30. otherwise is 0
DiscordLibraryLibrary "DiscordLibrary"
BoldString(str)
Bold String in Discord Function
Parameters:
str
ItalicizeString(str)
Italicize String in Discord Function
Parameters:
str
StrikeThroughString(str)
Strikethrough a String in Discord Function
Parameters:
str
UnderlineString(str)
Underline a String in Discord Function
Parameters:
str
SpoilerString(str)
When you send the text, it will be shown as a black block, and only by clicking on it will you be able to see what is written below, in a way, unveiling the text or giving spoilers
Parameters:
str
HighlightString(str)
Highlight String Function
Parameters:
str
BoxedString(str)
Put String in a Box Function
Parameters:
str
NonEmbeddedURLString(str)
Format URL String so that it is not an embedded Image but just the Link
Parameters:
str
InvisibleString(str)
Send Inivisible Text
Parameters:
str
FormatTimePeriodForDiscord(_timeperiod)
Parameters:
_timeperiod
GetDiscordEmbedJSON(_message, _avatarURL, _botName, _role, _color, _embed_title, _embed_subtitle, _title, _url, _icon_url, _icon2_url, _footer, _description)
Generate discord embed JSON
Parameters:
_message
_avatarURL
_botName
_role
_color
_embed_title
_embed_subtitle
_title
_url
_icon_url
_icon2_url
_footer
_description
GetDiscordTextJSON(_description)
Formats Content Only JSON Message
Parameters:
_description
Truncate(_number, _decimalPlaces)
Custom function to truncate (cut) excess decimal places
Parameters:
_number
_decimalPlaces
FormatDiscordMessage(_textmessage, _ticker, _timeframe)
format Content message
Parameters:
_textmessage
_ticker
_timeframe
FormatCoin(_coinText)
Format Ticker Symbol
Parameters:
_coinText
SessionInBoxesProLibrary "SessionInBoxesPro"
get_time_by_bar(bar_count)
Parameters:
bar_count
get_positions_func(sessiontime_, duration_)
Parameters:
sessiontime_
duration_
get_period(_session, _start, _lookback)
Parameters:
_session
_start
_lookback
is_start(_session)
Parameters:
_session
is_end(_session)
Parameters:
_session
draw_progress(_show, _session, _is_started, _is_ended, _color, _bottom, _delete_history)
Parameters:
_show
_session
_is_started
_is_ended
_color
_bottom
_delete_history
draw_label(_show, _session, _is_started, _color, _top, _bottom, _text, _delete_history, i_label_chg, i_label_size, i_label_position, i_tz, i_label_format_day)
Parameters:
_show
_session
_is_started
_color
_top
_bottom
_text
_delete_history
i_label_chg
i_label_size
i_label_position
i_tz
i_label_format_day
draw_fib(_show, _session, _is_started, _color, _top, _bottom, _level, _width, _style, _is_extend, _delete_history)
Parameters:
_show
_session
_is_started
_color
_top
_bottom
_level
_width
_style
_is_extend
_delete_history
get_op_stricts(_session, _is_started, top, bottom, i_o_minutes)
Parameters:
_session
_is_started
top
bottom
i_o_minutes
draw_op(_show, _session, _is_started, _color, top, bottom, _is_extend, _delete_history, i_o_minutes, i_o_opacity)
Parameters:
_show
_session
_is_started
_color
top
bottom
_is_extend
_delete_history
i_o_minutes
i_o_opacity
get_pm_stricts(_show, _show_pm, tf, ctf, _is_started)
Parameters:
_show
_show_pm
tf
ctf
_is_started
draw_pm(_show, _show_pm, tf, ctf, _is_started, _is_ended, _delete_history, _color)
Parameters:
_show
_show_pm
tf
ctf
_is_started
_is_ended
_delete_history
_color
draw_market(_show, _session, _is_started, _color, btr, _top, _bottom, _extend, _is_extend, _delete_history, i_sess_border_style, i_sess_border_width, i_sess_bgopacity)
Parameters:
_show
_session
_is_started
_color
btr
_top
_bottom
_extend
_is_extend
_delete_history
i_sess_border_style
i_sess_border_width
i_sess_bgopacity
draw(_show, _show_pm, pm_tf, ctf, _session, _color, btr, _label, _extend, _show_fib, _show_op, i_label_chg, i_label_size, i_label_position, i_o_minutes, i_o_opacity, i_sess_border_style, i_sess_border_width, i_sess_bgopacity, i_show_history, i_show_closed, i_label_show, i_f_linewidth, i_f_linestyle, top, bottom, i_tz, i_label_format_day)
Parameters:
_show
_show_pm
pm_tf
ctf
_session
_color
btr
_label
_extend
_show_fib
_show_op
i_label_chg
i_label_size
i_label_position
i_o_minutes
i_o_opacity
i_sess_border_style
i_sess_border_width
i_sess_bgopacity
i_show_history
i_show_closed
i_label_show
i_f_linewidth
i_f_linestyle
top
bottom
i_tz
i_label_format_day
UtilitiesLibrary "Utilities"
My utility functions library.
toPips(_v)
Convert price to pips.
Parameters:
_v : Price
Returns: Pips
toPrice(_p)
Convert pips to price.
Parameters:
_p
Returns: Price
price_range(_a, _b)
The difference will be returned.
Parameters:
_a
_b : @return Price as positive number
get_day(_n, _lang)
Get the day of the week
Parameters:
_n : Number of day of week
_lang : en or ja
source(_name)
TODO: add function description here
Parameters:
_name
Returns: TODO: add what function returns
clear_lines(_arr, _min)
Deletes the lines included in the array.
Parameters:
_arr : Array of lines
_min : Deletes the lines included in the array.
clear_labels(_arr, _min)
Deletes the labels included in the array.
Parameters:
_arr : Array of labels
_min : Deletes the labels included in the array.
clear_boxes(_arr, _min)
Deletes the boxes included in the array.
Parameters:
_arr : Array of boxes
_min : Deletes the boxes included in the array.
MLExtensionsLibrary "MLExtensions"
normalizeDeriv(src, quadraticMeanLength)
Returns the smoothed hyperbolic tangent of the input series.
Parameters:
src : The input series (i.e., the first-order derivative for price).
quadraticMeanLength : The length of the quadratic mean (RMS).
Returns: nDeriv The normalized derivative of the input series.
normalize(src, min, max)
Rescales a source value with an unbounded range to a target range.
Parameters:
src : The input series
min : The minimum value of the unbounded range
max : The maximum value of the unbounded range
Returns: The normalized series
rescale(src, oldMin, oldMax, newMin, newMax)
Rescales a source value with a bounded range to anther bounded range
Parameters:
src : The input series
oldMin : The minimum value of the range to rescale from
oldMax : The maximum value of the range to rescale from
newMin : The minimum value of the range to rescale to
newMax : The maximum value of the range to rescale to
Returns: The rescaled series
color_green(prediction)
Assigns varying shades of the color green based on the KNN classification
Parameters:
prediction : Value (int|float) of the prediction
Returns: color
color_red(prediction)
Assigns varying shades of the color red based on the KNN classification
Parameters:
prediction : Value of the prediction
Returns: color
tanh(src)
Returns the the hyperbolic tangent of the input series. The sigmoid-like hyperbolic tangent function is used to compress the input to a value between -1 and 1.
Parameters:
src : The input series (i.e., the normalized derivative).
Returns: tanh The hyperbolic tangent of the input series.
dualPoleFilter(src, lookback)
Returns the smoothed hyperbolic tangent of the input series.
Parameters:
src : The input series (i.e., the hyperbolic tangent).
lookback : The lookback window for the smoothing.
Returns: filter The smoothed hyperbolic tangent of the input series.
tanhTransform(src, smoothingFrequency, quadraticMeanLength)
Returns the tanh transform of the input series.
Parameters:
src : The input series (i.e., the result of the tanh calculation).
smoothingFrequency
quadraticMeanLength
Returns: signal The smoothed hyperbolic tangent transform of the input series.
n_rsi(src, n1, n2)
Returns the normalized RSI ideal for use in ML algorithms.
Parameters:
src : The input series (i.e., the result of the RSI calculation).
n1 : The length of the RSI.
n2 : The smoothing length of the RSI.
Returns: signal The normalized RSI.
n_cci(src, n1, n2)
Returns the normalized CCI ideal for use in ML algorithms.
Parameters:
src : The input series (i.e., the result of the CCI calculation).
n1 : The length of the CCI.
n2 : The smoothing length of the CCI.
Returns: signal The normalized CCI.
n_wt(src, n1, n2)
Returns the normalized WaveTrend Classic series ideal for use in ML algorithms.
Parameters:
src : The input series (i.e., the result of the WaveTrend Classic calculation).
n1
n2
Returns: signal The normalized WaveTrend Classic series.
n_adx(highSrc, lowSrc, closeSrc, n1)
Returns the normalized ADX ideal for use in ML algorithms.
Parameters:
highSrc : The input series for the high price.
lowSrc : The input series for the low price.
closeSrc : The input series for the close price.
n1 : The length of the ADX.
regime_filter(src, threshold, useRegimeFilter)
Parameters:
src
threshold
useRegimeFilter
filter_adx(src, length, adxThreshold, useAdxFilter)
filter_adx
Parameters:
src : The source series.
length : The length of the ADX.
adxThreshold : The ADX threshold.
useAdxFilter : Whether to use the ADX filter.
Returns: The ADX.
filter_volatility(minLength, maxLength, useVolatilityFilter)
filter_volatility
Parameters:
minLength : The minimum length of the ATR.
maxLength : The maximum length of the ATR.
useVolatilityFilter : Whether to use the volatility filter.
Returns: Boolean indicating whether or not to let the signal pass through the filter.
backtest(high, low, open, startLongTrade, endLongTrade, startShortTrade, endShortTrade, isStopLossHit, maxBarsBackIndex, thisBarIndex)
Performs a basic backtest using the specified parameters and conditions.
Parameters:
high : The input series for the high price.
low : The input series for the low price.
open : The input series for the open price.
startLongTrade : The series of conditions that indicate the start of a long trade.`
endLongTrade : The series of conditions that indicate the end of a long trade.
startShortTrade : The series of conditions that indicate the start of a short trade.
endShortTrade : The series of conditions that indicate the end of a short trade.
isStopLossHit : The stop loss hit indicator.
maxBarsBackIndex : The maximum number of bars to go back in the backtest.
thisBarIndex : The current bar index.
Returns: A tuple containing backtest values
init_table()
init_table()
Returns: tbl The backtest results.
update_table(tbl, tradeStatsHeader, totalTrades, totalWins, totalLosses, winLossRatio, winrate, stopLosses)
update_table(tbl, tradeStats)
Parameters:
tbl : The backtest results table.
tradeStatsHeader : The trade stats header.
totalTrades : The total number of trades.
totalWins : The total number of wins.
totalLosses : The total number of losses.
winLossRatio : The win loss ratio.
winrate : The winrate.
stopLosses : The total number of stop losses.
Returns: Updated backtest results table.
BasicVisibleChartBasic library for the visible range chart; with functions to allow plotting Fibs from body high/low as well as wick high/low
-Thanks to code from @PineCoders Visible Chart library (PineCoders/VisibleChart/4), which is a much more comprehensive library than this, but which does not include some functions that I find useful:
-Added the following exportable functions: highest/lowest body, highest/lowest close, highest/lowest open. These allow one to anchor fibs from bodies rather than wicks
-Added a Fib Box function in the example code
The above chart shows the example code plotting a Fib range drawn from bodies and a highlighted retracement zone (61.8 % - 78.6% )
~~All Exportable Functions~~
barIsVisible()
highestClose()
highestOpen()
highestBody()
lowestClose()
lowestOpen()
lowestBody()
high()
highBarTime()
low()
lowBarTime()
open()
close()
theme_presetsStyle Made Easy with 175 Reversable light/dark themes
Built on to of my theme engine, so any tools built with one
will work with the other.
getTheme(_input)
Get a theme by name. (see lib for copy/paste list)
Parameters:
_input : string Name of Theme to use.
apathy()
Theme preset -> "Apathy"
Returns: Theme object
apprentice()
Theme preset -> "Apprentice"
Returns: Theme object
ashes()
Theme preset -> "Ashes"
Returns: Theme object
atelier_cave()
Theme preset -> "Atelier Cave"
Returns: Theme object
atelier_dune()
Theme preset -> "Atelier Dune"
Returns: Theme object
atelier_estuary()
Theme preset -> "Atelier Estuary"
Returns: Theme object
atelier_forest()
Theme preset -> "Atelier Forest"
Returns: Theme object
atelier_heath()
Theme preset -> "Atelier Heath"
Returns: Theme object
atelier_lakeside()
Theme preset -> "Atelier Lakeside"
Returns: Theme object
atelier_plateau()
Theme preset -> "Atelier Plateau"
Returns: Theme object
atelier_savanna()
Theme preset -> "Atelier Savanna"
Returns: Theme object
atelier_seaside()
Theme preset -> "Atelier Seaside"
Returns: Theme object
atelier_sulphurpool()
Theme preset -> "Atelier Sulphurpool"
Returns: Theme object
atlas()
Theme preset -> "Atlas"
Returns: Theme object
ayu()
Theme preset -> "Ayu"
Returns: Theme object
ayu_mirage()
Theme preset -> "Ayu Mirage"
Returns: Theme object
bespin()
Theme preset -> "Bespin"
Returns: Theme object
black_metal()
Theme preset -> "Black Metal"
Returns: Theme object
black_metal_bathory()
Theme preset -> "Black Metal (bathory)"
Returns: Theme object
black_metal_burzum()
Theme preset -> "Black Metal (burzum)"
Returns: Theme object
black_metal_funeral()
Theme preset -> "Black Metal (dark Funeral)"
Returns: Theme object
black_metal_gorgoroth()
Theme preset -> "Black Metal (gorgoroth)"
Returns: Theme object
black_metal_immortal()
Theme preset -> "Black Metal (immortal)"
Returns: Theme object
black_metal_khold()
Theme preset -> "Black Metal (khold)"
Returns: Theme object
black_metal_marduk()
Theme preset -> "Black Metal (marduk)"
Returns: Theme object
black_metal_mayhem()
Theme preset -> "Black Metal (mayhem)"
Returns: Theme object
black_metal_nile()
Theme preset -> "Black Metal (nile)"
Returns: Theme object
black_metal_venom()
Theme preset -> "Black Metal (venom)"
Returns: Theme object
blue_forest()
Theme preset -> "Blue Forest"
Returns: Theme object
blueish()
Theme preset -> "Blueish"
Returns: Theme object
brewer()
Theme preset -> "Brewer"
Returns: Theme object
bright()
Theme preset -> "Bright"
Returns: Theme object
brogrammer()
Theme preset -> "Brogrammer"
Returns: Theme object
brush_trees()
Theme preset -> "Brush Trees"
Returns: Theme object
catppuccin()
Theme preset -> "Catppuccin"
Returns: Theme object
chalk()
Theme preset -> "Chalk"
Returns: Theme object
circus()
Theme preset -> "Circus"
Returns: Theme object
classic()
Theme preset -> "Classic"
Returns: Theme object
clrs()
Theme preset -> "Colors"
Returns: Theme object
codeschool()
Theme preset -> "Codeschool"
Returns: Theme object
cupcake()
Theme preset -> "Cupcake"
Returns: Theme object
cupertino()
Theme preset -> "Cupertino"
Returns: Theme object
da_one_black()
Theme preset -> "Da One Black"
Returns: Theme object
da_one_gray()
Theme preset -> "Da One Gray"
Returns: Theme object
da_one_ocean()
Theme preset -> "Da One Ocean"
Returns: Theme object
da_one_paper()
Theme preset -> "Da One Paper"
Returns: Theme object
da_one_sea()
Theme preset -> "Da One Sea"
Returns: Theme object
da_one_white()
Theme preset -> "Da One White"
Returns: Theme object
danqing()
Theme preset -> "Danqing"
Returns: Theme object
darcula()
Theme preset -> "Darcula"
Returns: Theme object
dark_violet()
Theme preset -> "Dark Violet"
Returns: Theme object
darkmoss()
Theme preset -> "Darkmoss"
Returns: Theme object
darktooth()
Theme preset -> "Darktooth"
Returns: Theme object
decaf()
Theme preset -> "Decaf"
Returns: Theme object
dirtysea()
Theme preset -> "Dirtysea"
Returns: Theme object
dracula()
Theme preset -> "Dracula"
Returns: Theme object
edge()
Theme preset -> "Edge"
Returns: Theme object
eighties()
Theme preset -> "Eighties"
Returns: Theme object
embers()
Theme preset -> "Embers"
Returns: Theme object
emil()
Theme preset -> "Emil"
Returns: Theme object
equilibrium()
Theme preset -> "Equilibrium"
Returns: Theme object
equilibrium_gray()
Theme preset -> "Equilibrium Gray"
Returns: Theme object
espresso()
Theme preset -> "Espresso"
Returns: Theme object
eva()
Theme preset -> "Eva"
Returns: Theme object
everforest()
Theme preset -> "Everforest"
Returns: Theme object
flat()
Theme preset -> "Flat"
Returns: Theme object
framer()
Theme preset -> "Framer"
Returns: Theme object
fruit_soda()
Theme preset -> "Fruit Soda"
Returns: Theme object
gigavolt()
Theme preset -> "Gigavolt"
Returns: Theme object
github()
Theme preset -> "Github"
Returns: Theme object
google()
Theme preset -> "Google"
Returns: Theme object
gotham()
Theme preset -> "Gotham"
Returns: Theme object
grayscale()
Theme preset -> "Grayscale"
Returns: Theme object
green_screen()
Theme preset -> "Green Screen"
Returns: Theme object
gruber()
Theme preset -> "Gruber"
Returns: Theme object
gruvbox_hard()
Theme preset -> "Gruvbox Dark, Hard"
Returns: Theme object
gruvbox_medium()
Theme preset -> "Gruvbox Dark, Medium"
Returns: Theme object
gruvbox_pale()
Theme preset -> "Gruvbox Dark, Pale"
Returns: Theme object
gruvbox_soft()
Theme preset -> "Gruvbox Dark, Soft"
Returns: Theme object
gruvbox_material_hard()
Theme preset -> "Gruvbox Material Dark, Hard"
Returns: Theme object
gruvbox_material_medium()
Theme preset -> "Gruvbox Material Dark, Medium"
Returns: Theme object
gruvbox_material_soft()
Theme preset -> "Gruvbox Material Dark, Soft"
Returns: Theme object
hardcore()
Theme preset -> "Hardcore"
Returns: Theme object
harmonic16()
Theme preset -> "Harmonic16"
Returns: Theme object
heetch()
Theme preset -> "Heetch"
Returns: Theme object
helios()
Theme preset -> "Helios"
Returns: Theme object
hopscotch()
Theme preset -> "Hopscotch"
Returns: Theme object
horizon()
Theme preset -> "Horizon"
Returns: Theme object
horizon_terminal()
Theme preset -> "Horizon Terminal"
Returns: Theme object
humanoid()
Theme preset -> "Humanoid"
Returns: Theme object
ia()
Theme preset -> "Ia"
Returns: Theme object
icy()
Theme preset -> "Icy"
Returns: Theme object
ir_black()
Theme preset -> "Ir Black"
Returns: Theme object
isotope()
Theme preset -> "Isotope"
Returns: Theme object
kanagawa()
Theme preset -> "Kanagawa"
Returns: Theme object
katy()
Theme preset -> "Katy"
Returns: Theme object
kimber()
Theme preset -> "Kimber"
Returns: Theme object
lime()
Theme preset -> "Lime"
Returns: Theme object
london_tube()
Theme preset -> "London Tube"
Returns: Theme object
macintosh()
Theme preset -> "Macintosh"
Returns: Theme object
marrakesh()
Theme preset -> "Marrakesh"
Returns: Theme object
materia()
Theme preset -> "Materia"
Returns: Theme object
material()
Theme preset -> "Material"
Returns: Theme object
materialdarker()
Theme preset -> "Material Darker"
Returns: Theme object
material_palenight()
Theme preset -> "Material Palenight"
Returns: Theme object
material_vivid()
Theme preset -> "Material Vivid"
Returns: Theme object
mellow_purple()
Theme preset -> "Mellow Purple"
Returns: Theme object
mocha()
Theme preset -> "Mocha"
Returns: Theme object
monokai()
Theme preset -> "Monokai"
Returns: Theme object
Nebula()
Theme preset -> "Nebula"
Returns: Theme object
nord()
Theme preset -> "Nord"
Returns: Theme object
nova()
Theme preset -> "Nova"
Returns: Theme object
ocean()
Theme preset -> "Ocean"
Returns: Theme object
oceanicnext()
Theme preset -> "Oceanicnext"
Returns: Theme object
onedark()
Theme preset -> "Onedark"
Returns: Theme object
outrun()
Theme preset -> "Outrun"
Returns: Theme object
pandora()
Theme preset -> "Pandora"
Returns: Theme object
papercolor()
Theme preset -> "Papercolor"
Returns: Theme object
paraiso()
Theme preset -> "Paraiso"
Returns: Theme object
pasque()
Theme preset -> "Pasque"
Returns: Theme object
phd()
Theme preset -> "Phd"
Returns: Theme object
pico()
Theme preset -> "Pico"
Returns: Theme object
pinky()
Theme preset -> "Pinky"
Returns: Theme object
pop()
Theme preset -> "Pop"
Returns: Theme object
porple()
Theme preset -> "Porple"
Returns: Theme object
primer()
Theme preset -> "Primer"
Returns: Theme object
purpledream()
Theme preset -> "Purpledream"
Returns: Theme object
qualia()
Theme preset -> "Qualia"
Returns: Theme object
railscasts()
Theme preset -> "Railscasts"
Returns: Theme object
rebecca()
Theme preset -> "Rebecca"
Returns: Theme object
rose_pine()
Theme preset -> "Rosé Pine"
Returns: Theme object
rose_pine_dawn()
Theme preset -> "Rosé Pine Dawn"
Returns: Theme object
rose_pine_moon()
Theme preset -> "Rosé Pine Moon"
Returns: Theme object
sagelight()
Theme preset -> "Sagelight"
Returns: Theme object
sakura()
Theme preset -> "Sakura"
Returns: Theme object
sandcastle()
Theme preset -> "Sandcastle"
Returns: Theme object
seti_ui()
Theme preset -> "Seti Ui"
Returns: Theme object
shades_of_purple()
Theme preset -> "Shades Of Purple"
Returns: Theme object
shadesmear()
Theme preset -> "Shadesmear"
Returns: Theme object
shapeshifter()
Theme preset -> "Shapeshifter"
Returns: Theme object
silk()
Theme preset -> "Silk"
Returns: Theme object
snazzy()
Theme preset -> "Snazzy"
Returns: Theme object
solar_flare()
Theme preset -> "Solar Flare"
Returns: Theme object
solarized()
Theme preset -> "Solarized"
Returns: Theme object
spaceduck()
Theme preset -> "Spaceduck"
Returns: Theme object
spacemacs()
Theme preset -> "Spacemacs"
Returns: Theme object
stella()
Theme preset -> "Stella"
Returns: Theme object
still_alive()
Theme preset -> "Still Alive"
Returns: Theme object
summercamp()
Theme preset -> "Summercamp"
Returns: Theme object
summerfruit()
Theme preset -> "Summerfruit"
Returns: Theme object
synth_midnight_terminal()
Theme preset -> "Synth Midnight Terminal"
Returns: Theme object
tango()
Theme preset -> "Tango"
Returns: Theme object
tender()
Theme preset -> "Tender"
Returns: Theme object
tokyo_city()
Theme preset -> "Tokyo City"
Returns: Theme object
tokyo_city_terminal()
Theme preset -> "Tokyo City Terminal"
Returns: Theme object
tokyo_night()
Theme preset -> "Tokyo Night"
Returns: Theme object
tokyo_night_storm()
Theme preset -> "Tokyo Night Storm"
Returns: Theme object
tokyo_night_terminal()
Theme preset -> "Tokyo Night Terminal"
Returns: Theme object
tokyo_night_terminal_storm()
Theme preset -> "Tokyo Night Terminal Storm"
Returns: Theme object
tokyodark()
Theme preset -> "Tokyodark"
Returns: Theme object
tokyodark_terminal()
Theme preset -> "Tokyodark Terminal"
Returns: Theme object
tomorrow()
Theme preset -> "Tomorrow"
Returns: Theme object
tomorrow_night()
Theme preset -> "Tomorrow Night"
Returns: Theme object
tomorrow_night_eighties()
Theme preset -> "Tomorrow Night Eighties"
Returns: Theme object
twilight()
Theme preset -> "Twilight"
Returns: Theme object
unikitty()
Theme preset -> "Unikitty"
Returns: Theme object
unikitty_reversible()
Theme preset -> "Unikitty Reversible"
Returns: Theme object
uwunicorn()
Theme preset -> "Uwunicorn"
Returns: Theme object
vice()
Theme preset -> "Vice"
Returns: Theme object
vulcan()
Theme preset -> "Vulcan"
Returns: Theme object
windows_10()
Theme preset -> "Windows 10"
Returns: Theme object
windows_95()
Theme preset -> "Windows 95"
Returns: Theme object
windows_high_contrast()
Theme preset -> "Windows High Contrast"
Returns: Theme object
windows_nt()
Theme preset -> "Windows Nt"
Returns: Theme object
woodland()
Theme preset -> "Woodland"
Returns: Theme object
xcode_dusk()
Theme preset -> "Xcode Dusk"
Returns: Theme object