easytableLibrary "easytable"
Create tables easily, with minimal code
▦ FEATURES ▦
█ Create tables █ JSON To Table █ Change Colors █ Array to Rows/Columns █ Pre-Styles █ Change Text Size █ Delete Rows/Columns █ Blink Cells
indentify_table_id() Identifies all tables ID number in each cell(0,0).
get_table_by_id(id_number) Get table object by ID number.
Parameters:
id_number : (int) ID number of the table to fetch.
Returns: table.
change_cells_color(table_object, cells_color, start_column, end_column, start_row, end_row) Change cells background colors.
Parameters:
table_object : (table) table object to be changed.
cells_color : (color) Cells color.
start_column : (int) Start column.
end_column : (int) End column.
start_row : (int) Start Row.
end_row : (int) End Row to change.
Returns: Void.
change_cells_text_color(table_object, text_color, start_column, end_column, start_row, end_row) Change cells text colors.
Parameters:
table_object : (table) table object to be changed.
text_color : (color) Text color.
start_column : (int) Start column.
end_column : (int) End column.
start_row : (int) Start Row.
end_row : (int) End Row.
Returns: Void.
change_all_table_text_color(table_object, text_color, table_column_size, table_row_size) Change All table text color.
Parameters:
table_object : (table) table object to be changed.
text_color : (color) Text color.
table_column_size : (int) Size of the table columns.
table_row_size : (int) Size of the table rows.
Returns: Void.
change_table_size(table_object, n_of_columns, n_of_rows, tbl_size) Change table size.
Parameters:
table_object : (table) table object to be changed.
n_of_columns : (int) Size of the table columns.
n_of_rows : (int) Size of the table rows.
tbl_size : (string) size of the table.
Returns: Void.
change_cells_text_size(text_size, start_column, end_column, start_row, end_row, table_id) Change table cells text size .
Parameters:
text_size : (string) Text size.
start_column : (int) Start column.
end_column : (int)(optional) End column.
start_row : (int)(optional) Start Row.
end_row : (int)(optional) End Row.
table_id : (int)(optional) Number of the ID of the table.
Returns: Void.
table_delete_row(table_object, table_column_size, start_row, end_row) Delete specified rows from table.
Parameters:
table_object : (table) table object to be changed.
table_column_size : (int) Table columns max size.
start_row : (int) Start row to delete.
end_row : (int)(optional) End row to delete (optional — Assumes start_row value).
Returns: Void.
table_delete_column(table_object, table_row_size, start_column, end_column) Delete specified columns from table.
Parameters:
table_object : (table) table object to be changed.
table_row_size : (int) Table rows max size.
start_column : (int) Start column to delete.
end_column : (int)(optional) End column to delete (optional — Assumes start_column value).
Returns: Void.
array_to_table_column_auto(column_to_insert, array_to_insert, table_id) Insert string array to table column without passing table object.
Parameters:
column_to_insert : (int) Column to be inserted.
array_to_insert : (string array) Start column to delete.
table_id : (int)(optional) Number of the ID of the table.
Returns: Void.
array_to_table_row_auto(row_to_insert, array_to_insert, table_id) Insert string array to table row without passing table object.
Parameters:
row_to_insert : (int) Column to be inserted.
array_to_insert : (string array) Start column to delete.
table_id : (int)(optional) Number of the ID of the table.
Returns: Void.
array_to_table_row(table_object, row_to_insert, array_to_insert) Insert string array to table row by passing table object.
Parameters:
table_object : (table) table object to be changed.
row_to_insert : (int) Row to be inserted.
array_to_insert : (string array) Start column to delete.
Returns: Void.
array_to_table_column(table_object, column_to_insert, array_to_insert) Insert string array to table column by passing table object.
Parameters:
table_object : (table) table object to be changed.
column_to_insert : (int) Column to be inserted.
array_to_insert : (string array) Start column to delete.
Returns: Void.
blink_cell(cell_column, cell_row, c_color, blink_interval_ms, table_id) Changes cell color at set intervals (blink).
Parameters:
cell_column : (int) Cell column position.
cell_row : (int) Cell row position.
c_color : (color) Color to blink.
blink_interval_ms : (int)(opt) Interval in milliseconds.
table_id : (int)(opt) Table ID number.
change_table_style(table_object, number_of_columns, number_of_rows, color) Changes table pre-style by selecting a pre-style number.
Parameters:
table_object : (table) table object to be changed.
number_of_columns : (int) Table column size.
number_of_rows : (int) Table row size.
color : 1 (color) Color of .
Returns: Void.
create_table_clean(n_of_columns, n_of_rows, position) Create a simple(blank) table without any styling.
Parameters:
n_of_columns : (int) Numbers of columns in the table.
n_of_rows : (int) Number of rows in the table.
position : (string) table position.
Returns: table object.
create_table_with_style(n_of_columns, n_of_rows, style_number, position) Create table with a pre-set style.
Parameters:
n_of_columns : (int) Numbers of columns in the table.
n_of_rows : (int) Number of rows in the table.
style_number : (int) Style number.
position : (string) table position.
Returns: table object.
json_to_table(raw_json) Create table based on input raw json string.
Parameters:
raw_json : (int) Raw json string.
Returns: table object.
json_example() Example function that display a table based on a json
example_create_table()
Indicators and strategies
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
timeUtilsLibrary "timeUtils"
Utils for time series
tradingDaysTillEndOfMonth() Calculates how many full trading days left until the end of the current month. (It doesn't take into account market holidays)
Returns: int series of the remaining trading days until the end of the month.
insideRange()
utilsLibrary "utils"
ma_smooth(alg, src, len) Calculates various moving averages
Parameters:
alg : Smoothing algorithm to use
src : Source data
len : Length of moving average
RVSILibrary "RVSI"
This Library contains functions that calculate all types of " Relative Volume Strength Index (MZ RVSI ) " depending upon unique volume oscillator. Achieved RVSI value can be used for divergence detection in volume or to adapt dynamic length in Moving Averages or other functions.
rvsi_tfs(vol_src, vol_Len, rvsiLen, _open, _close) Relative Volume Strength Index based on TFS Volume Oscillator
Parameters:
vol_src : Volume Source
vol_Len : Volume Legth for TFS Volume Oscillato
rvsiLen : Period of Relative Volume Strength Index
_open : Ticker Open Value
_close : Ticker Close Value
Returns: Relative Volume Strength Index value based on TFS Volume Oscillator
rvsi_obv(vol_src, rvsiLen, _close) Relative Volume Strength Index based on On Balance Volume
Parameters:
vol_src : Volume Source to Calculate On Balance Volume
rvsiLen : Period of Relative Volume Strength Index
_close : Ticker Close Value
Returns: Relative Volume Strength Index value based on On Balance Volume
rvsi_kvo(vol_src, FastX, SlowX, rvsiLen, _close) Relative Volume Strength Index based on Klinger Volume Oscillator
Parameters:
vol_src : Volume Source
FastX : Volume Fast Length
SlowX : Volume Slow Length
rvsiLen : Period of Relative Volume Strength Index
_close : Ticker Close Value
Returns: Relative Volume Strength Index value based on Klinger Volume Oscillator
rvsi_vzo(vol_src, zLen, rvsiLen, _close) Relative Volume Strength Index based on Volume Zone Oscillator
Parameters:
vol_src : Volume Source
zLen : Volume Legth for Volume Zone Oscillator
rvsiLen : Period of Relative Volume Strength Index
_close : Ticker Close Value
Returns: Relative Volume Strength Index value based on Volume Zone Oscillator
rvsi_cvo_obv(vol_src, ema1len, ema2len, rvsiLen) Relative Volume Strength Index based on Cumulative Volume Oscillator with On Balance Volume as Calculations Source
Parameters:
vol_src : Volume Source
ema1len : EMA Fast Length
ema2len : EMA Slow Length
rvsiLen : Period of Relative Volume Strength Index
Returns: Relative Volume Strength Index value based on Cumulative Volume Oscillator with On Balance Volume as Calculations Source
rvsi_cvo_pvt(vol_src, FastX, SlowX, rvsiLen) Relative Volume Strength Index based on Cumulative Volume Oscillator with Price Volume Trend as Calculations Source
Parameters:
vol_src : Volume Source
FastX : EMA Fast Length
SlowX : EMA Slow Length
rvsiLen : Period of Relative Volume Strength Index
Returns: Relative Volume Strength Index value based on Cumulative Volume Oscillator with Price Volume Trend as Calculations Source
rvsi_cvo_cvd(vol_src, FastX, SlowX, rvsiLen, _open, _close, _high, _low) Relative Volume Strength Index based on Cumulative Volume Oscillator with Cumulative Volume Delta as Calculations Source
Parameters:
vol_src : Volume Source
FastX : EMA Fast Length
SlowX : EMA Slow Length
rvsiLen : Period of Relative Volume Strength Index
_open : Ticker Open Value
_close : Ticker Close Value
_high : Ticker High Value
_low : Ticker Low Value
Returns: Relative Volume Strength Index value based on Cumulative Volume Oscillator with Cumulative Volume Delta as Calculations Source
eStrategyLibrary "eStrategy"
Library contains methods which can help build custom strategy for continuous investment plans and also compare it with systematic buy and hold.
sip(startYear, initialDeposit, depositFrequency, recurringDeposit, buyPrice) Depicts systematic buy and hold over period of time
Parameters:
startYear : Year on which SIP is started
initialDeposit : Initial one time investment at the start
depositFrequency : Frequency of recurring deposit - can be monthly or weekly
recurringDeposit : Recurring deposit amount
buyPrice : Indicatinve buy price. Use high to be conservative. low, close, open, hl2, hlc3, ohlc4, hlcc4 are other options.
Returns: totalInvestment - initial + recurring deposits
totalQty - Quantity of units held for given instrument
totalEquity - Present equity
customStrategy(startYear, initialDeposit, depositFrequency, recurringDeposit, buyPrice, sellPrice, initialInvestmentPercent, recurringInvestmentPercent, signal, tradePercent) Allows users to define custom strategy and enhance systematic buy and hold by adding take profit and reloads
Parameters:
startYear : Year on which SIP is started
initialDeposit : Initial one time investment at the start
depositFrequency : Frequency of recurring deposit - can be monthly or weekly
recurringDeposit : Recurring deposit amount
buyPrice : Indicatinve buy price. Use high to be conservative. low, close, open, hl2, hlc3, ohlc4, hlcc4 are other options.
sellPrice : Indicatinve sell price. Use low to be conservative. high, close, open, hl2, hlc3, ohlc4, hlcc4 are other options.
initialInvestmentPercent : percent of amount to invest from the initial depost. Keep rest of them as cash
recurringInvestmentPercent : percent of amount to invest from recurring deposit. Keep rest of them as cash
signal : can be 1, -1 or 0. 1 means buy/reload. -1 means take profit and 0 means neither.
tradePercent : percent of amount to trade when signal is not 0. If taking profit, it will sell the percent from existing position. If reloading, it will buy with percent from cash reserve
Returns: totalInvestment - initial + recurring deposits
totalQty - Quantity of units held for given instrument
totalCash = Amount of cash held
totalEquity - Overall equity = totalQty*close + totalCash
JohnEhlersFourierTransformLibrary "JohnEhlersFourierTransform"
Fourier Transform for Traders By John Ehlers, slightly modified to allow to inspect other than the 8-50 frequency spectrum.
reference:
www.mesasoftware.com
high_pass_filter(source) Detrended version of the data by High Pass Filtering with a 40 Period cutoff
Parameters:
source : float, data source.
Returns: float.
transformed_dft(source, start_frequency, end_frequency) DFT by John Elhers.
Parameters:
source : float, data source.
start_frequency : int, lower bound of the frequency window, must be a positive number >= 0, window must be less than or 30.
end_frequency : int, upper bound of the frequency window, must be a positive number >= 0, window must be less than or 30.
Returns: tuple with float, float array.
db_to_rgb(db, transparency) converts the frequency decibels to rgb.
Parameters:
db : float, decibels value.
transparency : float, transparency value.
Returns: color.
windowing_taAll Signals Are the Sum of Sines. When looking at real-world signals, you usually view them as a price changing over time. This is referred to as the time domain. Fourier’s theorem states that any waveform in the time domain can be represented by the weighted sum of sines and cosines. For example, take two sine waves, where one is three times as fast as the other–or the frequency is 1/3 the first signal. When you add them, you can see you get a different signal.
Although performing an FFT on a signal can provide great insight, it is important to know the limitations of the FFT and how to improve the signal clarity using windowing. When you use the FFT to measure the frequency component of a signal, you are basing the analysis on a finite set of data. The actual FFT transform assumes that it is a finite data set, a continuous spectrum that is one period of a periodic signal. For the FFT, both the time domain and the frequency domain are circular topologies, so the two endpoints of the time waveform are interpreted as though they were connected together. When the measured signal is periodic and an integer number of periods fill the acquisition time interval, the FFT turns out fine as it matches this assumption. However, many times, the measured signal isn’t an integer number of periods. Therefore, the finiteness of the measured signal may result in a truncated waveform with different characteristics from the original continuous-time signal, and the finiteness can introduce sharp transition changes into the measured signal. The sharp transitions are discontinuities.
When the number of periods in the acquisition is not an integer, the endpoints are discontinuous. These artificial discontinuities show up in the FFT as high-frequency components not present in the original signal. These frequencies can be much higher than the Nyquist frequency and are aliased between 0 and half of your sampling rate. The spectrum you get by using a FFT, therefore, is not the actual spectrum of the original signal, but a smeared version. It appears as if energy at one frequency leaks into other frequencies. This phenomenon is known as spectral leakage, which causes the fine spectral lines to spread into wider signals.
You can minimize the effects of performing an FFT over a noninteger number of cycles by using a technique called windowing. Windowing reduces the amplitude of the discontinuities at the boundaries of each finite sequence acquired by the digitizer. Windowing consists of multiplying the time record by a finite-length window with an amplitude that varies smoothly and gradually toward zero at the edges. This makes the endpoints of the waveform meet and, therefore, results in a continuous waveform without sharp transitions. This technique is also referred to as applying a window.
Here is a windowing_ta library with J.F Ehlers Windowing functions proposed on Sep, 2021.
Library "windowing_ta"
hann()
hamm()
fir_sma()
fir_triangle()
harmonicpatterns1Library "harmonicpatterns1"
harmonicpatterns: methods required for calculation of harmonic patterns. Correction for library (missing export in line 303)
isGartleyPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isGartleyPattern: Checks for harmonic pattern Gartley
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Gartley. False otherwise.
isBatPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isBatPattern: Checks for harmonic pattern Bat
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Bat. False otherwise.
isButterflyPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isButterflyPattern: Checks for harmonic pattern Butterfly
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Butterfly. False otherwise.
isCrabPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isCrabPattern: Checks for harmonic pattern Crab
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Crab. False otherwise.
isDeepCrabPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isDeepCrabPattern: Checks for harmonic pattern DeepCrab
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is DeepCrab. False otherwise.
isCypherPattern(xabRatio, axcRatio, xadRatio, err_min, err_max) isCypherPattern: Checks for harmonic pattern Cypher
Parameters:
xabRatio : AB/XA
axcRatio : XC/AX
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Cypher. False otherwise.
isSharkPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isSharkPattern: Checks for harmonic pattern Shark
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Shark. False otherwise.
isNenStarPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isNenStarPattern: Checks for harmonic pattern Nenstar
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Nenstar. False otherwise.
isAntiNenStarPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiNenStarPattern: Checks for harmonic pattern Anti NenStar
Parameters:
xabRatio : - AB/XA
abcRatio : - BC/AB
bcdRatio : - CD/BC
xadRatio : - AD/XA
err_min : - Minumum error threshold
err_max : - Maximum error threshold
Returns: True if the pattern is Anti NenStar. False otherwise.
isAntiSharkPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiSharkPattern: Checks for harmonic pattern Anti Shark
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Shark. False otherwise.
isAntiCypherPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiCypherPattern: Checks for harmonic pattern Anti Cypher
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Cypher. False otherwise.
isAntiCrabPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiCrabPattern: Checks for harmonic pattern Anti Crab
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Crab. False otherwise.
isAntiButterflyPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiButterflyPattern: Checks for harmonic pattern Anti Butterfly
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Butterfly. False otherwise.
isAntiBatPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiBatPattern: Checks for harmonic pattern Anti Bat
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Bat. False otherwise.
isAntiGartleyPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiGartleyPattern: Checks for harmonic pattern Anti Gartley
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Gartley. False otherwise.
isNavarro200Pattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isNavarro200Pattern: Checks for harmonic pattern Navarro200
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Navarro200. False otherwise.
isHarmonicPattern(x, a, c, c, d, flags, errorPercent) isHarmonicPattern: Checks for harmonic patterns
Parameters:
x : X coordinate value
a : A coordinate value
c : B coordinate value
c : C coordinate value
d : D coordinate value
flags : flags to check patterns. Send empty array to enable all
errorPercent : Error threshold
Returns: Array of boolean values which says whether valid pattern exist and array of corresponding pattern names
TS_FFALibrary "TS_FFA"
Splits the ticker and generates best configs for FP and PP
splitter(x) Splits the ticker and found the configuration regarding to name.
Parameters:
_x: ticker
Returns: Fib and Profit percent values
- Splitter had been added.
- USDTPERP coins on Binance had been added
- timeFrameMultiplier() timeframe multiplier had been added to the library
- timeframe period value fixed
- Changed timezone multiplier
- Changed VWMA Percent values
bytimeLibrary "bytime"
TODO: to do something at the specified time.
////Return =>> ht = hour , mt = minute , st = second ,Dt = Day, Mt = month, Yt = year , dateTime = full time format./////////////
Note : Remember to always add import when you call our library and change Gtime() to Timeset.Gtime() is used to access internal data.
import hapharmonic/bytime/1 as Timeset
=Timeset.Gtime()
/////////////Set a time to trigger an alert./////////////
ck = false
///hour : minute : second
if ht == TH and mt == TM and st == TS
//some action
//...
//.
ck := true
Gtime()
[e2] Drawing Library :: Horizontal Ray█ OVERVIEW
Library "e2hray"
A drawing library that contains the hray() function, which draws a horizontal ray/s with an initial point determined by a specified condition. It plots a ray until it reached the price. The function let you control the visibility of historical levels and setup the alerts.
█ HORIZONTAL RAY FUNCTION
hray(condition, level, color, extend, hist_lines, alert_message, alert_delay, style, hist_style, width, hist_width)
Parameters:
condition : Boolean condition that defines the initial point of a ray
level : Ray price level.
color : Ray color.
extend : (optional) Default value true, current ray levels extend to the right, if false - up to the current bar.
hist_lines : (optional) Default value true, shows historical ray levels that were revisited, default is dashed lines. To avoid alert problems set to 'false' before creating alerts.
alert_message : (optional) Default value string(na), if declared, enables alerts that fire when price revisits a line, using the text specified
alert_delay : (optional) Default value int(0), number of bars to validate the level. Alerts won't trigger if the ray is broken during the 'delay'.
style : (optional) Default value 'line.style_solid'. Ray line style.
hist_style : (optional) Default value 'line.style_dashed'. Historical ray line style.
width : (optional) Default value int(1), ray width in pixels.
hist_width : (optional) Default value int(1), historical ray width in pixels.
Returns: void
█ EXAMPLES
• Example 1. Single horizontal ray from the dynamic input.
//@version=5
indicator("hray() example :: Dynamic input ray", overlay = true)
import e2e4mfck/e2hray/1 as e2draw
inputTime = input.time(timestamp("20 Jul 2021 00:00 +0300"), "Date", confirm = true)
inputPrice = input.price(54, 'Price Level', confirm = true)
e2draw.hray(time == inputTime, inputPrice, color.blue, alert_message = 'Ray level re-test!')
var label mark = label.new(inputTime, inputPrice, 'Selected point to start the ray', xloc.bar_time)
• Example 2. Multiple horizontal rays on the moving averages cross.
//@version=5
indicator("hray() example :: MA Cross", overlay = true)
import e2e4mfck/e2hray/1 as e2draw
float sma1 = ta.sma(close, 20)
float sma2 = ta.sma(close, 50)
bullishCross = ta.crossover( sma1, sma2)
bearishCross = ta.crossunder(sma1, sma2)
plot(sma1, 'sma1', color.purple)
plot(sma2, 'sma2', color.blue)
// 1a. We can use 2 function calls to distinguish long and short sides.
e2draw.hray(bullishCross, sma1, color.green, alert_message = 'Bullish Cross Level Broken!', alert_delay = 10)
e2draw.hray(bearishCross, sma2, color.red, alert_message = 'Bearish Cross Level Broken!', alert_delay = 10)
// 1b. Or a single call for both.
// e2draw.hray(bullishCross or bearishCross, sma1, bullishCross ? color.green : color.red)
• Example 3. Horizontal ray at the all time highs with an alert.
//@version=5
indicator("hray() example :: ATH", overlay = true)
import e2e4mfck/e2hray/1 as e2draw
var float ath = 0, ath := math.max(high, ath)
bool newAth = ta.change(ath)
e2draw.hray(nz(newAth ), high , color.orange, alert_message = 'All Time Highs Tested!', alert_delay = 10)
TAExtLibrary "TAExt"
Indicator functions can be used in other indicators and strategies. This will be extended by time with indicators I use in my strategies and studies.
atrwo(length, stdev_length, stdev_mult) ATR without outliers
Parameters:
length : The length of the ATR
stdev_length : The length of the standard deviation, used for detecting outliers
stdev_mult : The multiplier of the standard deviation, used for detecting outliers
Returns: The ATR value
atrwma(src, period, type, atr_length, stdev_length, stdev_mult) ATR without outlier weighted moving average
Parameters:
src : The source of the moving average
period : The period of the moving average
type : The type of the moving average, possible values: SMA, EMA, RMA
atr_length : The length of the ATR
stdev_length : The length of the standard deviation, used for detecting outliers
stdev_mult : The multiplier of the standard deviation, used for detecting outliers
Returns: The moving average value
jma(src, period, phase, power) Jurik Moving Average
Parameters:
src : The source of the moving average
period : The period of the moving average calculation
phase : The phase of jurik MA calculation (-100..100)
power : The power of jurik MA calculation
Returns: The Jurik MA series
anyma(src, period, type, offset, sigma, phase, power) Moving Average by type
Parameters:
src : The source of the moving average
period : The period of the moving average calculation
type : The type of the moving average
offset : Used only by ALMA, it is the ALMA offset
sigma : Used only by ALMA, it is the ALMA sigma
phase : The phase of jurik MA calculation (-100..100)
power : The power of jurik MA calculation
Returns: The moving average series
wae(macd_src, macd_fast_length, macd_slow_length, macd_sensitivity, bb_base_src, bb_upper_src, bb_lower_src, bb_length, bb_mult, dead_zone_length, dead_zone_mult) Waddah Attar Explosion (WAE)
Parameters:
macd_src : The source series used by MACD
macd_fast_length : The fast MA length of the MACD
macd_slow_length : The slow MA length of the MACD
macd_sensitivity : The MACD diff multiplier
bb_base_src : The source used by stdev
bb_upper_src : The source used by the upper Bollinger Band
bb_lower_src : The source used by the lower Bollinger Band
bb_length : The lenth for Bollinger Bands
bb_mult : The multiplier for Bollinger Bands
dead_zone_length : The ATR length for dead zone calculation
dead_zone_mult : The ATR multiplier for dead zone
Returns:
ssl(length, high_src, low_src) Semaphore Signal Level channel (SSL)
Parameters:
length : The length of the moving average
high_src : Source of the high moving average
low_src : Source of the low moving average
Returns:
adx(atr_length, di_length, adx_length, high_src, low_src, atr_ma_type, di_ma_type, adx_ma_type) Average Directional Index + Direction Movement Index (ADX + DMI)
Parameters:
atr_length : The length of ATR
di_length : DI plus and minus smoothing length
adx_length : ADX smoothing length
high_src : Source of the high moving average
low_src : Source of the low moving average
atr_ma_type : MA type of the ATR calculation
di_ma_type : MA type of the DI calculation
adx_ma_type : MA type of the ADX calculation
Returns:
FunctionCosineSimilarityLibrary "FunctionCosineSimilarity"
Cosine Similarity method.
function(sample_a, sample_b) Measure the similarity of 2 vectors.
Parameters:
sample_a : float array, values.
sample_b : float array, values.
Returns: float.
diss(cosim) Dissimilarity helper function.
Parameters:
cosim : float, cosine similarity value (0 > 1)
Returns: float
historicalrangeLibrary "historicalrange"
Library provices a method to calculate historical percentile range of series.
hpercentrank(source) calculates historical percentrank of the source
Parameters:
source : Source for which historical percentrank needs to be calculated. Source should be ranging between 0-100. If using a source which can beyond 0-100, use short term percentrank to baseline them.
Returns: pArray - percentrank array which contains how many instances of source occurred at different levels.
upperPercentile - percentile based on higher value
lowerPercentile - percentile based on lower value
median - median value of the source
max - max value of the source
distancefromath(source) returns stats on historical distance from ath in terms of percentage
Parameters:
source : for which stats are calculated
Returns: percentile and related historical stats regarding distance from ath
distancefromma(maType, length, source) returns stats on historical distance from moving average in terms of percentage
Parameters:
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow, linreg, median
length : Moving Average Length
source : for which stats are calculated
Returns: percentile and related historical stats regarding distance from ath
bpercentb(source, maType, length, multiplier, sticky) returns percentrank and stats on historical bpercentb levels
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow, linreg, median
length : Moving Average Length
multiplier : Standard Deviation multiplier
sticky : - sticky boundaries which will only change when value is outside boundary.
Returns: percentile and related historical stats regarding Bollinger Percent B
kpercentk(source, maType, length, multiplier, useTrueRange, sticky) returns percentrank and stats on historical kpercentk levels
Parameters:
source : Moving Average Source
maType : Moving Average Type : Can be sma, ema, hma, rma, wma, vwma, swma, highlow, linreg, median
length : Moving Average Length
multiplier : Standard Deviation multiplier
useTrueRange : - if set to false, uses high-low.
sticky : - sticky boundaries which will only change when value is outside boundary.
Returns: percentile and related historical stats regarding Keltener Percent K
dpercentd(useAlternateSource, alternateSource, length, sticky) returns percentrank and stats on historical dpercentd levels
Parameters:
useAlternateSource : - Custom source is used only if useAlternateSource is set to true
alternateSource : - Custom source
length : - donchian channel length
sticky : - sticky boundaries which will only change when value is outside boundary.
Returns: percentile and related historical stats regarding Donchian Percent D
oscillator(type, length, shortLength, longLength, source, highSource, lowSource, method, highlowLength, sticky) oscillator - returns Choice of oscillator with custom overbought/oversold range
Parameters:
type : - oscillator type. Valid values : cci, cmo, cog, mfi, roc, rsi, stoch, tsi, wpr
length : - Oscillator length - not used for TSI
shortLength : - shortLength only used for TSI
longLength : - longLength only used for TSI
source : - custom source if required
highSource : - custom high source for stochastic oscillator
lowSource : - custom low source for stochastic oscillator
method : - Valid values for method are : sma, ema, hma, rma, wma, vwma, swma, highlow, linreg, median
highlowLength : - length on which highlow of the oscillator is calculated
sticky : - overbought, oversold levels won't change unless crossed
Returns: percentile and related historical stats regarding oscillator
ZxLibraryLibrary "ZxLibrary"
ZxLibrary is an easy with more than 130 Indicators and more than 60 Candlestick Patterns.
dc_taAdaptive technical indicators are importants in a non stationary market, the ability to adapt to a situation can boost the efficiency of your strategy. A lot of methods have been proposed to make technical indicators "smarters", the dominant cycle tuned indicators are one of them which are based on J.F.Ehlers theory. Here is a collections of algorithms to calculate dominant cycles. ENJOY!
Library "dc_ta"
bton()
EhlersHoDyDC()
EhlersPhAcDC()
EhlersDuDiDC()
EhlersCycPer()
EhlersCycPer2()
EhlersBPZC()
EhlersAutoPer()
EhlersHoDyDCE()
EhlersPhAcDCE()
EhlersDuDiDCE()
EhlersDFTDC()
EhlersDFTDC2()
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.
Logger Library For Pinescript (Logging and Debugging)Library "LoggerLib"
This is a logging library for Pinescript. It is aimed to help developers testing and debugging scripts with a simple to use logger function.
Pinescript lacks a native logging implementation. This library would be helpful to mitigate this insufficiency.
This library uses table to print outputs into its view. It is simple, customizable and robust.
You can start using it's .log() method just like any other logging method in other languages.
//////////////////
USAGE
//////////////////
-- Recommended: Please Read The Documentation From Source Code Below. It Is Much More Readable There And Will Be Updated Along With Newer Versions. --
Importing the Library
---------------------
import paragjyoti2012/LoggerLib/ as Logger
.init() : Initializes the library and returns the logger pointer. (Later will be used as a function parameter)
.initTable: Initializes the Table View for the Logger and returns the table id. (Later will be used as a function parameter)
parameters:
logger: The logger pointer got from .init()
max_rows_count: Number of Rows to display in the Logger Table (default is 10)
offset: The offset value for the rows (Used for scrolling the view)
position: Position of the Table View
Values could be:
left
right
top-right
(default is left)
size: Font Size of content
Values could be:
small
normal
large
(default is small)
hide_date: Whether to hide the Date/Time column in the Logger (default is false)
returns: Table
example usage of .initTable()
import paragjyoti2012/LoggerLib/1 as Logger
var logger=Logger.init()
var logTable=Logger.initTable(logger, max_rows_count=20, offset=0, position="top-right")
-------------------
LOGGING
-------------------
.log() : Logging Method
params: (string message, |string| logger, table table_id, string type="message")
logger: pass the logger pointer from .init()
table_id: pass the table pointer from .initTable()
message: The message to log
type: Type of the log message
Values could be:
message
warning
error
info
success
(default is message)
returns: void
///////////////////////////////////////
Full Boilerplate For Using In Indicator
///////////////////////////////////////
P.S: Change the | (pipe) character into square brackets while using in script (or copy it from the source code instead)
offset=input.int(0,"Offset",minval=0)
size=input.string("small","Font Size",options=|"normal","small","large"|)
rows=input.int(15,"No Of Rows")
position=input.string("left","Position",options=|"left","right","top-right"|)
hide_date=input.bool(false,"Hide Time")
import paragjyoti2012/LoggerLib/1 as Logger
var logger=Logger.init()
var logTable=Logger.initTable(logger,rows,offset,position,size,hide_date)
rsi=ta.rsi(close,14)
|macd,signal,hist|=ta.macd(close,12,26,9)
if(ta.crossunder(close,34000))
Logger.log("Dropped Below 34000",logger,logTable,"warning")
if(ta.crossunder(close,35000))
Logger.log("Dropped Below 35000",logger,logTable)
if(ta.crossover(close,38000))
Logger.log("Crossed 38000",logger,logTable,"info")
if(ta.crossunder(rsi,20))
Logger.log("RSI Below 20",logger,logTable,"error")
if(ta.crossover(macd,signal))
Logger.log("Macd Crossed Over Signal",logger,logTable)
if(ta.crossover(rsi,80))
Logger.log("RSI Above 80",logger,logTable,"success")
////////////////////////////
// For Scrolling the Table View
////////////////////////////
There is a subtle way of achieving nice scrolling behaviour for the Table view. Open the input properties panel for the table/indicator. Focus on the input field for "Offset", once it's focused, you could use your mouse scroll wheel to increment/decrement the offset values; It will smoothly scroll the Logger Table Rows as well.
/////////////////////
For any assistance using this library or reporting issues, please write in the comment section below.
I will try my best to guide you and update the library. Thanks :)
/////////////////////
FunctionWeekofmonthLibrary "FunctionWeekofmonth"
Week of Month function.
weekofmonth(utime) Week of month for provided unix time.
Parameters:
utime : int, unix timestamp.
Returns: int
interval_taA pine V5 library with several functions to handle time and sessions in trading.
Library "interval_ta"
bton()
tir()
nbs()
ismarket()
isclose()
dow()
tp1_timestamp()
datetime()
noldo_taI'm a follower of Noldo, and I've learned almost all of his published scripts. I like some of the basic functions he wrote so much that I decided to collect them as a noldo_ta library file to share. Most of these functions are the same as Noldo's version, and there are some interesting algorithmic processing, which I also encapsulated into functions. Enjoy.
COURTESY OF NOLDO for these intersting functions!
Library "noldo_ta"
bton()
f_ema()
f_highest()
f_lowest()
f_rma()
f_rsi()
f_stoch()
f_kdj()
f_sum()
f_sma()
f_stdev()
f_bb()
f_pearson_corr()
f_multiple_corr()
f_adjusted_r_squared()
f_mfi()
dow()
pivothl()
f_adjusted_r_squared2()
linreg()
f_roc()
f_macd()
f_mom()
f_wma()
f_hull()
f_vwma()
f_obv()
f_sar()
f_stochastic()
f_stochrsi()
f_stochmfi()
f_kst()
f_smahist()
f_emahist()
f_fisher()
f_ao()
f_accdist()
f_highestbars()
f_lowestbars()
WIPNNetworkLibrary "WIPNNetwork"
this is a work in progress (WIP) and prone to have some errors, so use at your own risk...
let me know if you find any issues..
Method for a generalized Neural Network.
network(x) Generalized Neural Network Method.
Parameters:
x : TODO: add parameter x description here
Returns: TODO: add what function returns