Library: ArrayLibrary "xarray"
Additional functions for array.
remove_duplicates(array_in)
Remove duplicates in array.
Parameters:
array_in : (int /float /string ) Array contains duplicates.
Returns: Array without duplicates.
// Example: int
import tuele99/xarray/1 as xarray
c = xarray.remove_duplicates(array.from(1, 4, 2, 1, 2))
plot(array.size(c))
plot(array.get(c, 0))
plot(array.get(c, 1))
// Example: float
import tuele99/xarray/1 as xarray
c = xarray.remove_duplicates(array.from(1.0, 4.0, 2.0, 1.0, 2.0))
plot(array.size(c))
plot(array.get(c, 0))
plot(array.get(c, 1))
// Example: string
import tuele99/xarray/1 as xarray
c = xarray.remove_duplicates(array.from("green", "red", "green", "red", "green"))
plot(array.size(c)) // value = 2
label0 = label.new(x=last_bar_index, y=0, yloc=yloc.belowbar, text=array.get(c, 0), style=label.style_label_left, color=color.new(color.black, 100), textcolor=color.green) // below text = "green"
label1 = label.new(x=last_bar_index, y=0, yloc=yloc.abovebar, text=array.get(c, 1), style=label.style_label_left, color=color.new(color.black, 100), textcolor=color.red) // above text = "red"
Array
Alternative MTF Table█ OVERVIEW
This indicator is an educational indicator which was stripped down from Regression Channel Alternative MTF to display 3 timeframes based on timeframe scenarios.
The timeframe scenarios are defined based on Position, Swing and Intraday Trader.
█ INSPIRATION
It is possible to use array.new_bool, array.indexof and switch to get this outcome. Credits to TradingView .
pta_plotLibrary "pta_plot"
pta_plot: This library will help you to plot different value. I will keep updating with your requirement
print_array(array_id, border_color)
Display array element as a table.
Parameters:
array_id : Id of your array.
border_color : Color for border (`color.black` is used if no argument is supplied).
Returns: Display array element in bottom of the pane.
HarmonicCalculation█ OVERVIEW
This library is complementary for XABCD Harmonic Pattern Custom Range Interactive
PriceDiff()
: Price Difference
Parameters:
: : price_1, price_2
Returns: : PriceDiff
TimeDiff()
: Time Difference
Parameters:
: : time_1, time_2
Returns: : TimeDiff
ReturnIndexOf3Arrays()
: Return Index Of 3 Arrays
Parameters:
: : id1, id2, id3, _int
Returns: : ReturnIndexOf3Arrays
AbsoluteRange()
: Price Difference
Parameters:
: : price, y, point
Returns: : AbsoluteRange
PriceAverage()
: To calculate average of 2 prices
Parameters:
: : price_1, price_2
Returns: : PriceAverage
TimeAverage()
: To calculate average of 2 times
Parameters:
: : time_1, time_2
Returns: : TimeAverage
StringBool()
: To show ratio in 3 decimals format
Parameters:
: : _value, _bool, _text
Returns: : StringBool
PricePercent()
: To show Price in percent format
Parameters:
: : _price, PriceRef, str_dir
Returns: : PricePercent
BoolCurrency()
: To show syminfo.currency
Parameters:
: : _bool
Returns: : BoolCurrency
RatioText()
: To show RatioText in 3 decimals format
Parameters:
: : _value, _text
Returns: : RatioText
RangeText()
: To display RangeText in Harmonic Range Format
Parameters:
: : _id1, _id2, _int, _text
Returns: : RangeText
PriceCurrency()
: To show Currency in Price Format
Parameters:
: : _bool, _value
Returns: : PriceCurrency
"Swap" - Bool/Position/Value : Array / Matrix / Var AutoswapLibrary "swap"
Side / Boundary Based All Types Swapper
- three automagical types for Arrays, Matrixes, and Variables
-- no signal : Long/ Short position autoswap
-- true / false : Boolean based side choice
-- Src / Thresh : if source is above or below the threshold
- two operating modes for variables, Holding mode only for arrays/matrixes
-- with two items, will automatically change between the two caveat is it does not delete table/box/line(fill VAR items automatically)
-- with three items, a neutral is available for NA input or neutral
- one function name for all of them. One import name that's easy to type/remember
-- make life easy for your conditional items.
side(source, thresh, _a, _b, _c)
side Change outputs based on position or a crossing level
Parameters:
source : (float) OPTIONAL value input
thresh : (float) OPTIONAL boundary line to cross
_a : (any) if Long/True/Above
_b : (any) if Short/False/Below
_c : (any) OPTIONAL NOT FOR MTX OR ARR... Neutral Item, if var/varip on a/b it will leave behind, ie, a table or box or line will not erase , if it's a varip you're sending in.
Returns: first, second, or third items based on input conditions
Please notify if bugs found.
Thanks.
Harmonic Table Combo Point B█ OVERVIEW
This indicator was intended as educational purpose only and alternative way to show value in table as shown in Harmonic Pattern Possibility Table .
█ CREDITS
Credit to Scott M Carney, Harmonic Trading Volume 3: Reaction vs. Reversal.
█ USAGE EXAMPLE
[LIB] Array / Matrix DisplayLibrary "ArrayMatrixHUD"
Show Array or Matrix Elements In Table
For Arrays: Set the number of rows you want the data displayed in and it will generate a table, calculating the columns based on the size of the array being displayed.
For Matrix: It will automatically match the Rows and Columns to the values in the matrix.
Note: On the left, the table shows the index of the array/matrix value starting at 1. So, to call that value from inside the array, subtract 1 from the index value to the left. For matrices, keep in mind that the row and column are also starting at one when trying to call a value from the matrix. The numbering of the values on the left is for display purposes only.
viewArray(_arrayName, _pos, _txtSize, _tRows)
Array Element Display (Supports float, int, string, and bool)
Parameters:
_arrayName : ID of Array to be Displayed
_pos : Position for Table
_txtSize : Size of Table Cell Text
_tRows : Number of Rows to Display Data In (columns will be calculated accordingly)
Returns: A Display of Array Values in a Table
viewMatrix(_matrixName, _pos, _txtSize)
Matrix Element Display (Supports float, int, string, and bool)
Parameters:
_matrixName : ID of Matrix to be Displayed
_pos : Position for Table
_txtSize : Size of Table Cell Text
Returns: A Display of Matrix Values in a Table
Harmonic Pattern Possibility Table█ OVERVIEW
This indicator was intended as educational purpose only based on Harmonic Pattern Table (Source Code) and Ratio For Harmonic Points to show Harmonic Pattern Possibility.
█ INSPIRATION
This indicator was build upon realizing there are some overlap for B = XA among Alternate Bat, Bat, Crab and Gartley.
Hence, the values split up to showcase the possibility of non overlap ratio.
█ USAGE
Possible pattern, priority pattern and selected pattern may differs based value input.
Therefore C = AB, D = BC, D = XA and Stop Loss will change based value input and also selected pattern.
█ CREDITS
Credit to Scott M Carney, Harmonic Trading Volume 3: Reaction vs. Reversal.
ColorArrayLibrary "ColorArray"
Simple color array gradient tool.
makeGradient(size, _col1, _col2, _col3, _col4, _col5) Color Gradient Array from 5 colors.
Parameters:
size : : default 10
_col1 : : default #ff0000
_col2 : : default #ffff00
_col3 : : default #00ff00
_col4 : : default #00ffff
_col5 : : default #0000ff
Returns: array of colors to specified size.
[HELPER] Math Constant Helper█ OVERVIEW
This indicator is to show constant in table using built-in math name space, coded in latest Pine Script version 5.
█ CREDITS
Credits to PineCoders.
█ FEATURES
- Display table by changing table position, font size and color.
Ratio For Harmonic Points█ OVERVIEW
This indicator was intended as educational purpose only based on Harmonic Pattern Table (Source Code) to show indication of ratio for each Harmonic points from Point B until Stop Loss.
█ CREDITS
Credit to Scott M Carney, Harmonic Trading Volume 3: Reaction vs. Reversal.
█ USAGE EXAMPLE
Education: INDEXThis is an INDEX page where educational links/scripts are sorted in the script itself (see below)
For example:
- where is the link of the 'var' article/idea?
-> search in the script comments below for Keywords -> var -> look for the date ->
now you will find the link at the date of update
Selamat Hari RayaA fun way to express Selamat Aidil Fitri to all muslims.
Selamat Hari Raya Aidil Fitri
Maaf Zahir Dan Batin.
Pivot Points High Low Multi Time FrameHello All,
There are built-in and published Pivot Point High Low indicators in Public Library but as far as I see none of them is for Higher Time frames. so I decided to write & publish this script. I hope it would be useful while trading or developing your own scripts. I also did this to use in one of my future projects (we will see it in a few weeks/months ;) ).
I tried to make all settings optional, so you can play with them as you wish.
P.S. There is no control mechanism if the chart time frame is lower than the time frame in the options. So you better set higher time frame in the options than the chart time frame.
Enjoy!
Input Text Area to Array then Reshape Table█ OVERVIEW
Simple method to convert from input.text_area to array using str.split.
Reshape table using switch, not necessary must use matrix.reshape.
Might be useful pine script to replace input.symbol.
█ FEATURES
Table can positioned by any position and font size can be resized.
Reshape table and sorting array if necessary.
█ CREDITS
Credits to TradingView for new update of input.text_area.
SymMatrixTableSimple Example Table for Displaying Price, RSI, Volume of multiple Tickers on selected Timeframe
Displays Price, RSI and Volume of 3 Tickers and Timeframe selected by user input
Conditional Table Cell coloring
Price color green if > than previous candle close and red if < previous candle close
RSI color green if < 30 and red if > 70 (RSI14 by default)
Volume color green if above average volume and red if less than that (SMA20 volume by default)
Can turn on/off whole table, header columns, row indices, or select individual columns or rows to show/hide
// Example Mixed Type Matrix To Table //
access the simple example script by uncommenting the code at the end
Basically I wanted to have the headers and indices as strings and the rest of the matrix for the table body as floats, then conditional coloring on the table cells
And also the functionality to turn rows and columns on/off from table through checkboxes of user input
Before I was storing each of the values separately in arrays that didn't have a centralized way of controlling table structure
so now the structure is :
- string header array, string index array
- float matrix for table body
- color matrix with bool conditions for coloring table cells
- bool checkboxes for controlling table display
jsonLibrary "json"
Convert JSON strings to tradingview
▦ FEATURES ▦
█ Json to array █ Get json key names █ Get json key values █ Size of json
get_json_keys_names(raw_json) Returns string array with all key names
Parameters:
raw_json : (string) Raw JSON string
Returns: (string array) Array with all key names
get_values_by_id_name(raw_json, key_name) Returns string array with values of the input key name
Parameters:
raw_json : (string) Raw JSON string
key_name : (string) Name of the key to be fetched
Returns: (string array) Array with values of the input key name
size_of_json_string(raw_json) Returns size of raw JSON string
Parameters:
raw_json : (string) Raw JSON string
Returns: Size of n_of_values, size of n_of_keys_names
[HELPER] Table Color For Pairing Black And White█ OVERVIEW
This helper intend to simplify which color pair better with black or white color, may help some pine coders.
█ INSPIRATION
This color choice was inspired during plot especially user enable dark color theme.
Color displayed at table and label are based on Indicator name label and Indicator last value label displayed at Scales.
█ FEATURES
Color can be tick to be inverted color.
Display table by changing table position and font size.
ArrayOperationsLibrary "ArrayOperations"
Array element wise basic operations.
add(sample_a, sample_b) Adds sample_b to sample_a and returns a new array.
Parameters:
sample_a : values to be added to.
sample_b : values to add.
Returns: array with added results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
subtract(sample_a, sample_b) Subtracts sample_b from sample_a and returns a new array.
sample_a : values to be subtracted from.
sample_b : values to subtract.
Returns: array with subtracted results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
multiply(sample_a, sample_b) multiply sample_a by sample_b and returns a new array.
sample_a : values to multiply.
sample_b : values to multiply with.
Returns: array with multiplied results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
divide(sample_a, sample_b) Divide sample_a by sample_b and returns a new array.
sample_a : values to divide.
sample_b : values to divide with.
Returns: array with divided results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
power(sample_a, sample_b) power sample_a by sample_b and returns a new array.
sample_a : values to power.
sample_b : values to power with.
Returns: float array with power results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
remainder(sample_a, sample_b) Remainder sample_a by sample_b and returns a new array.
sample_a : values to remainder.
sample_b : values to remainder with.
Returns: array with remainder results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
equal(sample_a, sample_b) Check element wise sample_a equals sample_b and returns a new array.
sample_a : values to check.
sample_b : values to check.
Returns: int array with results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
not_equal(sample_a, sample_b) Check element wise sample_a not equals sample_b and returns a new array.
sample_a : values to check.
sample_b : values to check.
Returns: int array with results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
over_or_equal(sample_a, sample_b) Check element wise sample_a over or equals sample_b and returns a new array.
sample_a : values to check.
sample_b : values to check.
Returns: int array with results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
under_or_equal(sample_a, sample_b) Check element wise sample_a under or equals sample_b and returns a new array.
sample_a : values to check.
sample_b : values to check.
Returns: int array with results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
over(sample_a, sample_b) Check element wise sample_a over sample_b and returns a new array.
sample_a : values to check.
sample_b : values to check.
Returns: int array with results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
under(sample_a, sample_b) Check element wise sample_a under sample_b and returns a new array.
sample_a : values to check.
sample_b : values to check.
Returns: int array with results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
and_(sample_a, sample_b) Check element wise sample_a and sample_b and returns a new array.
sample_a : values to check.
sample_b : values to check.
Returns: int array with results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
or_(sample_a, sample_b) Check element wise sample_a or sample_b and returns a new array.
sample_a : values to check.
sample_b : values to check.
Returns: int array with results.
- sample_a provides type format for output.
- arrays do not need to be symmetric.
- sample_a must have same or more elements than sample_b
all(sample) Check element wise if all numeric samples are true (!= 0).
sample : values to check.
Returns: int.
any(sample) Check element wise if any numeric samples are true (!= 0).
sample : values to check.
Returns: int.
ArrayExtLibrary "ArrayExt"
Array extensions
get(a, idx) Get element from the array at index, or na if index not found
Parameters:
a : The array
idx : The array index to get
Returns: The array item if exists or na
get(a, idx) Get element from the array at index, or na if index not found
Parameters:
a : The array
idx : The array index to get
Returns: The array item if exists or na
get(a, idx) Get element from the array at index, or na if index not found
Parameters:
a : The array
idx : The array index to get
Returns: The array item if exists or na
get(a, idx) Get element from the array at index, or na if index not found
Parameters:
a : The array
idx : The array index to get
Returns: The array item if exists or na
get(a, idx) Get element from the array at index, or na if index not found
Parameters:
a : The array
idx : The array index to get
Returns: The array item if exists or na
get(a, idx) Get element from the array at index, or na if index not found
Parameters:
a : The array
idx : The array index to get
Returns: The array item if exists or na
set(a, idx, val) Set array item at index, if array has no index at the specified index, the array is filled with na
Parameters:
a : The array
idx : The array index to set
val : The value to be set
set(a, idx, val) Set array item at index, if array has no index at the specified index, the array is filled with na
Parameters:
a : The array
idx : The array index to set
val : The value to be set
set(a, idx, val) Set array item at index, if array has no index at the specified index, the array is filled with na
Parameters:
a : The array
idx : The array index to set
val : The value to be set
set(a, idx, val) Set array item at index, if array has no index at the specified index, the array is filled with na
Parameters:
a : The array
idx : The array index to set
val : The value to be set
set(a, idx, val) Set array item at index, if array has no index at the specified index, the array is filled with na
Parameters:
a : The array
idx : The array index to set
val : The value to be set
set(a, idx, val) Set array item at index, if array has no index at the specified index, the array is filled with na
Parameters:
a : The array
idx : The array index to set
val : The value to be set
FunctionMinkowskiDistanceLibrary "FunctionMinkowskiDistance"
Method for Minkowski Distance,
The Minkowski distance or Minkowski metric is a metric in a normed vector space
which can be considered as a generalization of both the Euclidean distance and
the Manhattan distance.
It is named after the German mathematician Hermann Minkowski.
reference: en.wikipedia.org
double(point_ax, point_ay, point_bx, point_by, p_value) Minkowsky Distance for single points.
Parameters:
point_ax : float, x value of point a.
point_ay : float, y value of point a.
point_bx : float, x value of point b.
point_by : float, y value of point b.
p_value : float, p value, default=1.0(1: manhatan, 2: euclidean), does not support chebychev.
Returns: float
ndim(point_x, point_y, p_value) Minkowsky Distance for N dimensions.
Parameters:
point_x : float array, point x dimension attributes.
point_y : float array, point y dimension attributes.
p_value : float, p value, default=1.0(1: manhatan, 2: euclidean), does not support chebychev.
Returns: float
AveragesLibrary "Averages"
Contains utilities for generating averages from arrays. Useful for manipulated or cleaned data.
triangular(src, startingWeight) Calculates the triangular weighted average of a set of values where the last value has the highest weight.
Parameters:
src : The array to derive the average from.
startingWeight : The weight to begin with when calculating the average. Higher numbers will decrease the bias.
weighted(src, weights, weightDefault) Calculates the weighted average of a set of values.
Parameters:
src : The array to derive the average from.
weights : The array containing the weights for the source.
weightDefault : The default value to use when a weight is NA.
triangularWeighted(src, weights, startingWeight) Calculates the weighted average of a set of values where the last value has the highest triangular multiple.
Parameters:
src : The array to derive the average from.
weights : The array containing the weights for the source.
startingWeight : The multiple to begin with when calculating the average. Higher numbers will decrease the bias.
exponential(src) Calculates the exponential average of a set of values where the last value has the highest weight.
Parameters:
src : The array to derive the average from.
arrayFrom(src, len, omitNA) Creates an array from the provided series (oldest to newest).
Parameters:
src : The array to derive from.
len : The target length of the array.
omitNA : If true, NA values will not be added to the array and the resultant array may be shorter than the target length.
[HELPER] Symbol Info Array Table HelperThis indicator is to show symbol info in table using built-in syminfo name space, coded in latest Pine Script version 5.
Credits to PineCoders and Everget
Features :
- Display table by changing table position, font size and color.
- Show / Hide necessary symbol info.