lib_unitLibrary "lib_unit"
functions for assertions and unit testing
method init(this)
Namespace types: Test
Parameters:
this (Test)
method is_true(this, expression, message)
assert that expression is true, if it's false a runtime error will be thrown
Namespace types: Test
Parameters:
this (Test)
expression (bool) : The value to be true
message (string) : The message to print in the runtime error
method is_false(this, expression, message)
assert that expression is false, if it's true a runtime error will be thrown
Namespace types: Test
Parameters:
this (Test)
expression (bool) : The value to be false
message (string) : The message to print in the runtime error
method equals(this, expression, expected, message)
assert if expression and expected are equal, if they don't match a runtime error will be thrown
Namespace types: Test
Parameters:
this (Test)
expression (string) : The value to test
expected (string) : The expected value
message (string) : The message to print in the runtime error
method equals(this, expression, expected, message)
assert if expression and expected are equal, if they don't match a runtime error will be thrown
Namespace types: Test
Parameters:
this (Test)
expression (int) : The value to test
expected (int) : The expected value
message (string) : The message to print in the runtime error
method equals(this, expression, expected, message)
assert if expression and expected are equal, if they don't match a runtime error will be thrown
Namespace types: Test
Parameters:
this (Test)
expression (float) : The value to test
expected (float) : The expected value
message (string) : The message to print in the runtime error
method equals(this, expression, expected, message)
assert if expression and expected are equal, if they don't match a runtime error will be thrown. This version is testing length, order and values
Namespace types: Test
Parameters:
this (Test)
expression (string ) : The array to test
expected (string ) : The expected array
message (string) : The message to print in the runtime error
method equals(this, expression, expected, message)
assert if expression and expected are equal, if they don't match a runtime error will be thrown. This version is testing length, order and values
Namespace types: Test
Parameters:
this (Test)
expression (int ) : The array to test
expected (int ) : The expected array
message (string) : The message to print in the runtime error
method equals(this, expression, expected, message)
assert if expression and expected are equal, if they don't match a runtime error will be thrown. This version is testing length, order and values
Namespace types: Test
Parameters:
this (Test)
expression (float ) : The array to test
expected (float ) : The expected array
message (string) : The message to print in the runtime error
method not_na(this, expression, message)
assert if expression is not na, if it is a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression (string) : The value to test
message (string) : The message to print in the runtime error
method not_na(this, expression, message)
assert if expression is not na, if it is a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression (int) : The value to test
message (string) : The message to print in the runtime error
method not_na(this, expression, message)
assert if expression is not na, if it is a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression (float) : The value to test
message (string) : The message to print in the runtime error
method not_na(this, expression, message)
assert if expression is not na, if it is a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression (string ) : The value to test
message (string) : The message to print in the runtime error
method not_na(this, expression, message)
assert if expression is not na, if it is a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression (int ) : The value to test
message (string) : The message to print in the runtime error
method not_na(this, expression, message)
assert if expression is not na, if it is a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression (float ) : The value to test
message (string) : The message to print in the runtime error
method gt(this, expression1, expression2, message)
assert that expression1 > expression2, if it is not, a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression1 (int) : The value that should be greater
expression2 (int) : The value that should be lesser
message (string) : The message to print in the runtime error
method gt(this, expression1, expression2, message)
assert that expression1 > expression2, if it is not, a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression1 (float) : The value that should be greater
expression2 (int) : The value that should be lesser
message (string) : The message to print in the runtime error
method gte(this, expression1, expression2, message)
assert that expression1 >= expression2, if it is not, a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression1 (int) : The value that should be greater or equal
expression2 (int) : The value that should be lesser or equal
message (string) : The message to print in the runtime error
method gte(this, expression1, expression2, message)
assert that expression1 >= expression2, if it is not, a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression1 (float) : The value that should be greater or equal
expression2 (int) : The value that should be lesser or equal
message (string) : The message to print in the runtime error
method lt(this, expression1, expression2, message)
assert that expression1 < expression2, if it is not, a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression1 (int) : The value that should be lesser
expression2 (int) : The value that should be greater
message (string) : The message to print in the runtime error
method lt(this, expression1, expression2, message)
assert that expression1 < expression2, if it is not, a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression1 (float) : The value that should be lesser
expression2 (int) : The value that should be greater
message (string) : The message to print in the runtime error
method lte(this, expression1, expression2, message)
assert that expression1 <= expression2, if it is not, a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression1 (int) : The value that should be lesser or equal
expression2 (int) : The value that should be greater or equal
message (string) : The message to print in the runtime error
method lte(this, expression1, expression2, message)
assert that expression1 <= expression2, if it is not, a runtime error will be thrown.
Namespace types: Test
Parameters:
this (Test)
expression1 (float) : The value that should be lesser or equal
expression2 (int) : The value that should be greater or equal
message (string) : The message to print in the runtime error
Test
Fields:
strict (series__bool)
verbose (series__bool)
logger (|robbatt/lib_log/2;Logger|#OBJ)
Indikatoren und Strategien
lib_logLibrary "lib_log"
library for logging and debugging pine scripts
method init(this)
Namespace types: Logger
Parameters:
this (Logger)
method debug(this, message, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger to add the entry to
message (string) : The Message to add
condition (bool) : optional flag to enable disable logging of this entry dynamically (default: true)
method info(this, message, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger to add the entry to
message (string) : The Message to add
condition (bool) : optional flag to enable disable logging of this entry dynamically (default: true)
method success(this, message, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger to add the entry to
message (string) : The Message to add
condition (bool) : optional flag to enable disable logging of this entry dynamically (default: true)
method warning(this, message, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger to add the entry to
message (string) : The Message to add
condition (bool) : optional flag to enable disable logging of this entry dynamically (default: true)
method error(this, message, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger to add the entry to
message (string) : The Message to add
condition (bool) : optional flag to enable disable logging of this entry dynamically (default: true)
method debug_bar(this, message, bar, y, y_offset, last_only, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger object to check global min level condition
message (string) : The string to print
bar (int) : The bar to print the label at (default: bar_index)
y (float) : The price value to print at (default: high)
y_offset (float) : A price offset from y if you want to print multiple labels at the same spot
last_only (bool)
condition (bool)
method info_bar(this, message, bar, y, y_offset, last_only, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger object to check global min level condition
message (string) : The string to print
bar (int) : The bar to print the label at (default: bar_index)
y (float) : The price value to print at (default: high)
y_offset (float) : A price offset from y if you want to print multiple labels at the same spot
last_only (bool)
condition (bool)
method success_bar(this, message, bar, y, y_offset, last_only, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger object to check global min level condition
message (string) : The string to print
bar (int) : The bar to print the label at (default: bar_index)
y (float) : The price value to print at (default: high)
y_offset (float) : A price offset from y if you want to print multiple labels at the same spot
last_only (bool)
condition (bool)
method warning_bar(this, message, bar, y, y_offset, last_only, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger object to check global min level condition
message (string) : The string to print
bar (int) : The bar to print the label at (default: bar_index)
y (float) : The price value to print at (default: high)
y_offset (float) : A price offset from y if you want to print multiple labels at the same spot
last_only (bool)
condition (bool)
method error_bar(this, message, bar, y, y_offset, last_only, condition)
Namespace types: Logger
Parameters:
this (Logger) : Logger object to check global min level condition
message (string) : The string to print
bar (int) : The bar to print the label at (default: bar_index)
y (float) : The price value to print at (default: high)
y_offset (float) : A price offset from y if you want to print multiple labels at the same spot
last_only (bool)
condition (bool)
LogEntry
Fields:
timestamp (series__integer)
bar (series__integer)
level (series__integer)
message (series__string)
Logger
Fields:
min_level (series__integer)
color_logs (series__bool)
max_lines (series__integer)
line_idx (series__integer)
table_pos (series__string)
display (series__table)
log (array__|LogEntry|#OBJ)
DerivativeAlertPlaceHoldersLibrary "DerivativeAlertPlaceHolders"
TODO: Creation of Placeholders for Alerts, for using in FNO segment.
BasicPH(CustomMessage)
Parameters:
CustomMessage (string) : TODO: Requires Custom Input of Message
Returns: TODO: String with PH
CustomPlaceHoldersFNO(CustomInputMessage, InputPrice)
Parameters:
CustomInputMessage (string) : TODO: Requires Custom Input of Message
InputPrice (float)
Returns: TODO: Alert String with PH used in major FNO alert Segments
VolatilityIndicatorsLibrary "VolatilityIndicators"
This is a library of Volatility Indicators .
It aims to facilitate the grouping of this category of indicators, and also offer the customized supply of
the parameters and sources, not being restricted to just the closing price.
@Thanks and credits:
1. Dynamic Zones: Leo Zamansky, Ph.D., and David Stendahl
2. Deviation: Karl Pearson (code by TradingView)
3. Variance: Ronald Fisher (code by TradingView)
4. Z-score: Veronique Valcu (code by HPotter)
5. Standard deviation: Ronald Fisher (code by TradingView)
6. ATR (Average True Range): J. Welles Wilder (code by TradingView)
7. ATRP (Average True Range Percent): millerrh
8. Historical Volatility: HPotter
9. Min-Max Scale Normalization: gorx1
10. Mean Normalization: gorx1
11. Standardization: gorx1
12. Scaling to unit length: gorx1
13. LS Volatility Index: Alexandre Wolwacz (Stormer), Fabrício Lorenz, Fábio Figueiredo (Vlad) (code by me)
14. Bollinger Bands: John Bollinger (code by TradingView)
15. Bollinger Bands %: John Bollinger (code by TradingView)
16. Bollinger Bands Width: John Bollinger (code by TradingView)
dev(source, length, anotherSource)
Deviation. Measure the difference between a source in relation to another source
Parameters:
source (float)
length (simple int) : (int) Sequential period to calculate the deviation
anotherSource (float) : (float) Source to compare
Returns: (float) Bollinger Bands Width
variance(src, mean, length, biased, degreesOfFreedom)
Variance. A statistical measurement of the spread between numbers in a data set. More specifically,
variance measures how far each number in the set is from the mean (average), and thus from every other number in the set.
Variance is often depicted by this symbol: σ2. It is used by both analysts and traders to determine volatility and market security.
Parameters:
src (float) : (float) Source to calculate variance
mean (float) : (float) Mean (Moving average)
length (simple int) : (int) The sequential period to calcule the variance (number of values in data set)
biased (simple bool) : (bool) Defines the type of standard deviation. If true, uses biased sample variance (n),
degreesOfFreedom (simple int) : (int) Degrees of freedom. The number of values in the final calculation of a statistic that are free to vary.
Default value is n-1, where n here is length. Only applies when biased parameter is defined as true.
Returns: (float) Standard deviation
stDev(src, length, mean, biased, degreesOfFreedom)
Measure the Standard deviation from a source in relation to it's moving average.
In this implementation, you pass the average as a parameter, allowing a more personalized calculation.
Parameters:
src (float) : (float) Source to calculate standard deviation
length (simple int) : (int) The sequential period to calcule the standard deviation
mean (float) : (float) Moving average.
biased (simple bool) : (bool) Defines the type of standard deviation. If true, uses biased sample variance (n),
else uses unbiased sample variance (n-1 or another value, as long as it is in the range between 1 and n-1), where n=length.
degreesOfFreedom (simple int) : (int) Degrees of freedom. The number of values in the final calculation of a statistic that are free to vary.
Default value is n-1, where n here is length.
Returns: (float) Standard deviation
zscore(src, mean, length, biased, degreesOfFreedom)
Z-Score. A z-score is a statistical measurement that indicates how many standard deviations a data point is from
the mean of a data set. It is also known as a standard score. The formula for calculating a z-score is (x - μ) / σ,
where x is the individual data point, μ is the mean of the data set, and σ is the standard deviation of the data set.
Z-scores are useful in identifying outliers or extreme values in a data set. A positive z-score indicates that the
data point is above the mean, while a negative z-score indicates that the data point is below the mean. A z-score of
0 indicates that the data point is equal to the mean.
Z-scores are often used in hypothesis testing and determining confidence intervals. They can also be used to compare
data sets with different units or scales, as the z-score standardizes the data. Overall, z-scores provide a way to
measure the relative position of a data point in a data
Parameters:
src (float) : (float) Source to calculate z-score
mean (float) : (float) Moving average.
length (simple int) : (int) The sequential period to calcule the standard deviation
biased (simple bool) : (bool) Defines the type of standard deviation. If true, uses biased sample variance (n),
else uses unbiased sample variance (n-1 or another value, as long as it is in the range between 1 and n-1), where n=length.
degreesOfFreedom (simple int) : (int) Degrees of freedom. The number of values in the final calculation of a statistic that are free to vary.
Default value is n-1, where n here is length.
Returns: (float) Z-score
atr(source, length)
ATR: Average True Range. Customized version with source parameter.
Parameters:
source (float) : (float) Source
length (simple int) : (int) Length (number of bars back)
Returns: (float) ATR
atrp(length, sourceP)
ATRP (Average True Range Percent)
Parameters:
length (simple int) : (int) Length (number of bars back) for ATR
sourceP (float) : (float) Source for calculating percentage relativity
Returns: (float) ATRP
atrp(source, length, sourceP)
ATRP (Average True Range Percent). Customized version with source parameter.
Parameters:
source (float) : (float) Source for ATR
length (simple int) : (int) Length (number of bars back) for ATR
sourceP (float) : (float) Source for calculating percentage relativity
Returns: (float) ATRP
historicalVolatility(lengthATR, lengthHist)
Historical Volatility
Parameters:
lengthATR (simple int) : (int) Length (number of bars back) for ATR
lengthHist (simple int) : (int) Length (number of bars back) for Historical Volatility
Returns: (float) Historical Volatility
historicalVolatility(source, lengthATR, lengthHist)
Historical Volatility
Parameters:
source (float) : (float) Source for ATR
lengthATR (simple int) : (int) Length (number of bars back) for ATR
lengthHist (simple int) : (int) Length (number of bars back) for Historical Volatility
Returns: (float) Historical Volatility
minMaxNormalization(src, numbars)
Min-Max Scale Normalization. Maximum and minimum values are taken from the sequential range of
numbars bars back, where numbars is a number defined by the user.
Parameters:
src (float) : (float) Source to normalize
numbars (simple int) : (int) Numbers of sequential bars back to seek for lowest and hightest values.
Returns: (float) Normalized value
minMaxNormalization(src, numbars, minimumLimit, maximumLimit)
Min-Max Scale Normalization. Maximum and minimum values are taken from the sequential range of
numbars bars back, where numbars is a number defined by the user.
In this implementation, the user explicitly provides the desired minimum (min) and maximum (max) values for the scale,
rather than using the minimum and maximum values from the data.
Parameters:
src (float) : (float) Source to normalize
numbars (simple int) : (int) Numbers of sequential bars back to seek for lowest and hightest values.
minimumLimit (simple float) : (float) Minimum value to scale
maximumLimit (simple float) : (float) Maximum value to scale
Returns: (float) Normalized value
meanNormalization(src, numbars, mean)
Mean Normalization
Parameters:
src (float) : (float) Source to normalize
numbars (simple int) : (int) Numbers of sequential bars back to seek for lowest and hightest values.
mean (float) : (float) Mean of source
Returns: (float) Normalized value
standardization(src, mean, stDev)
Standardization (Z-score Normalization). How "outside the mean" values relate to the standard deviation (ratio between first and second)
Parameters:
src (float) : (float) Source to normalize
mean (float) : (float) Mean of source
stDev (float) : (float) Standard Deviation
Returns: (float) Normalized value
scalingToUnitLength(src, numbars)
Scaling to unit length
Parameters:
src (float) : (float) Source to normalize
numbars (simple int) : (int) Numbers of sequential bars back to seek for lowest and hightest values.
Returns: (float) Normalized value
lsVolatilityIndex(movingAverage, sourceHvol, lengthATR, lengthHist, lenNormal, lowerLimit, upperLimit)
LS Volatility Index. Measures the volatility of price in relation to an average.
Parameters:
movingAverage (float) : (float) A moving average
sourceHvol (float) : (float) Source for calculating the historical volatility
lengthATR (simple int) : (float) Length for calculating the ATR (Average True Range)
lengthHist (simple int) : (float) Length for calculating the historical volatility
lenNormal (simple int) : (float) Length for normalization
lowerLimit (simple int)
upperLimit (simple int)
Returns: (float) LS Volatility Index
lsVolatilityIndex(sourcePrice, movingAverage, sourceHvol, lengthATR, lengthHist, lenNormal, lowerLimit, upperLimit)
LS Volatility Index. Measures the volatility of price in relation to an average.
Parameters:
sourcePrice (float) : (float) Source for measure the distance
movingAverage (float) : (float) A moving average
sourceHvol (float) : (float) Source for calculating the historical volatility
lengthATR (simple int) : (float) Length for calculating the ATR (Average True Range)
lengthHist (simple int) : (float) Length for calculating the historical volatility
lenNormal (simple int)
lowerLimit (simple int)
upperLimit (simple int)
Returns: (float) LS Volatility Index
bollingerBands(src, length, mult, basis)
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. In this version you can pass a customized basis (moving average), not only SMA.
Parameters:
src (float) : (float) Source to calculate standard deviation used in Bollinger Bands
length (simple int) : (int) The time period to be used in calculating the standard deviation
mult (simple float) : (float) Multiplier used in standard deviation. Basically, the upper/lower bands are standard deviation multiplied by this.
basis (float) : (float) Basis of Bollinger Bands (a moving average)
Returns: (float) A tuple of Bollinger Bands, where index 1=basis; 2=basis+dev; 3=basis-dev; and dev=multiplier*stdev
bollingerBands(src, length, aMult, basis)
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. In this version you can pass a customized basis (moving average), not only SMA.
Also, various multipliers can be passed, thus getting more bands (instead of just 2).
Parameters:
src (float) : (float) Source to calculate standard deviation used in Bollinger Bands
length (simple int) : (int) The time period to be used in calculating the standard deviation
aMult (float ) : (float ) An array of multiplies used in standard deviation. Basically, the upper/lower bands are standard deviation multiplied by this.
This array of multipliers permit the use of various bands, not only 2.
basis (float) : (float) Basis of Bollinger Bands (a moving average)
Returns: (float ) An array of Bollinger Bands, where:
index 1=basis; 2=basis+dev1; 3=basis-dev1; 4=basis+dev2, 5=basis-dev2, 6=basis+dev2, 7=basis-dev2, Nup=basis+devN, Nlow=basis-devN
and dev1, dev2, devN are ```multiplier N * stdev```
bollingerBandsB(src, length, mult, basis)
Bollinger Bands %B - or Percent Bandwidth (%B).
Quantify or display where price (or another source) is in relation to the bands.
%B can be useful in identifying trends and trading signals.
Calculation:
%B = (Current Price - Lower Band) / (Upper Band - Lower Band)
Parameters:
src (float) : (float) Source to calculate standard deviation used in Bollinger Bands
length (simple int) : (int) The time period to be used in calculating the standard deviation
mult (simple float) : (float) Multiplier used in standard deviation
basis (float) : (float) Basis of Bollinger Bands (a moving average)
Returns: (float) Bollinger Bands %B
bollingerBandsB(src, length, aMult, basis)
Bollinger Bands %B - or Percent Bandwidth (%B).
Quantify or display where price (or another source) is in relation to the bands.
%B can be useful in identifying trends and trading signals.
Calculation
%B = (Current Price - Lower Band) / (Upper Band - Lower Band)
Parameters:
src (float) : (float) Source to calculate standard deviation used in Bollinger Bands
length (simple int) : (int) The time period to be used in calculating the standard deviation
aMult (float ) : (float ) Array of multiplier used in standard deviation. Basically, the upper/lower bands are standard deviation multiplied by this.
This array of multipliers permit the use of various bands, not only 2.
basis (float) : (float) Basis of Bollinger Bands (a moving average)
Returns: (float ) An array of Bollinger Bands %B. The number of results in this array is equal the numbers of multipliers passed via parameter.
bollingerBandsW(src, length, mult, basis)
Bollinger Bands Width. Serve as a way to quantitatively measure the width between the Upper and Lower Bands
Calculation:
Bollinger Bands Width = (Upper Band - Lower Band) / Middle Band
Parameters:
src (float) : (float) Source to calculate standard deviation used in Bollinger Bands
length (simple int) : (int) Sequential period to calculate the standard deviation
mult (simple float) : (float) Multiplier used in standard deviation
basis (float) : (float) Basis of Bollinger Bands (a moving average)
Returns: (float) Bollinger Bands Width
bollingerBandsW(src, length, aMult, basis)
Bollinger Bands Width. Serve as a way to quantitatively measure the width between the Upper and Lower Bands
Calculation
Bollinger Bands Width = (Upper Band - Lower Band) / Middle Band
Parameters:
src (float) : (float) Source to calculate standard deviation used in Bollinger Bands
length (simple int) : (int) Sequential period to calculate the standard deviation
aMult (float ) : (float ) Array of multiplier used in standard deviation. Basically, the upper/lower bands are standard deviation multiplied by this.
This array of multipliers permit the use of various bands, not only 2.
basis (float) : (float) Basis of Bollinger Bands (a moving average)
Returns: (float ) An array of Bollinger Bands Width. The number of results in this array is equal the numbers of multipliers passed via parameter.
dinamicZone(source, sampleLength, pcntAbove, pcntBelow)
Get Dynamic Zones
Parameters:
source (float) : (float) Source
sampleLength (simple int) : (int) Sample Length
pcntAbove (simple float) : (float) Calculates the top of the dynamic zone, considering that the maximum values are above x% of the sample
pcntBelow (simple float) : (float) Calculates the bottom of the dynamic zone, considering that the minimum values are below x% of the sample
Returns: A tuple with 3 series of values: (1) Upper Line of Dynamic Zone;
(2) Lower Line of Dynamic Zone; (3) Center of Dynamic Zone (x = 50%)
Examples:
Risk ManagementLibrary "RiskManagement"
This library keeps your money in check, and is used for testing and later on webhook-applications too. It has four volatility functions and two of them can be used to calculate a Stop-Loss, like Average True Range. It also can calculate Position Size, and the Risk Reward Ratio. But those calculations don't take leverage into account.
position_size(portfolio, risk, entry, stop_loss, use_leverage, qty_as_integer)
This function calculates the definite amount of contracts/shares/units you should use to buy or sell. This value can used by `strategy.entry(qty)` for example.
Parameters:
portfolio (float) : This is the total amount of the currency you own, and is also used by strategy.initial_capital, for example. The amount is needed to calculate the maximum risk you are willing to take per trade.
risk (float) : This is the percentage of your Portfolio you willing to loose on a single trade. Possible values are between 0.1 and 100%. Same usecase with strategy(default_qty_type=strategy.percent_of_equity,default_qty_value=100), except its calculation the risk only.
entry (float) : This is the limit-/market-price for the investment. In other words: The price per contract/share/unit you willing to buy or sell.
stop_loss (float) : This is the limit-/market-price when to exit the trade, to minimize your losses.
use_leverage (bool) : This value is optional. When not used or when set to false then this function will let you invest your portfolio at max.
qty_as_integer (bool) : This value is optional. When set to true this function will return a value used with integers. The largest integer less than or equal to the given number. Because some Broker/Exchanges let you trade hole contracts/shares/units only.
Returns: float
position_size_currency(portfolio, risk, entry, stop_loss)
This function calculates the definite amount of currency you should use when going long or short.
Parameters:
portfolio (float) : This is the total amount of the currency you own, and is also used by strategy.initial_capital, for example. The amount is needed to calculate the maximum risk you are willing to take per trade.
risk (float) : This is the percentage of your Portfolio you willing to loose on a single trade. For example: 1 is 100% and 0,01 is 1%. Default amount is 0.02 (2%).
entry (float) : This is the limit-/market-price for the current investment. In other words: The price per contract/share/units you willing to buy or sell.
stop_loss (float) : This is the limit-/market-price when to exit the trade, to minimize your losses.
Returns: float
rrr(entry, stop_loss, take_profit)
This function calculates the Risk Reward Ratio. Common values are between 1.5 and 2.0 and you should not go lower except for very few special cases.
Parameters:
entry (float) : This is the limit-/market-price for the investment. In other words: The price per contract/share/unit you willing to buy or sell.
stop_loss (float) : This is the limit-/market-price when to exit the trade, to minimize your losses.
take_profit (float) : This is the limit-/market-price when to take profits.
Returns: float
change_in_price(length)
This function calculates the difference between price now and close price of the candle 'n' bars before that. If prices are very volatile but closed where they began, then this method would show zero volatility. Over many calculations, this method returns a reasonable measure of volatility, but will always be lower than those using the highs and lows.
Parameters:
length (int) : The length is needed to determine how many candles/bars back should take into account.
Returns: float
maximum_price_fluctuation(length)
This function measures volatility over most recent candles, which could be used as an estimate of risk. It may also be effective as the basis for a stop-loss or take-profit, like the ATR but it ignores the frequency of directional changes within the time interval. In other words: The difference between the highest high and lowest low over 'n' bars.
Parameters:
length (int) : The length is needed to determine how many candles/bars back should take into account.
Returns: float
absolute_price_changes(length)
This function measures volatility over most recent close prices. This is excellent for comparing volatility. It includes both frequency and magnitude. In other words: Sum of differences between second to last close price and last close price as absolute value for 'n' bars.
Parameters:
length (int) : The length is needed to determine how many candles/bars back should take into account.
Returns: float
annualized_volatility(length)
This function measures volatility over most recent close prices. Its the standard deviation of close over the past 'n' periods, times the square root of the number of periods in a year.
Parameters:
length (int) : The length is needed to determine how many candles/bars back should take into account.
Returns: float
DebugLibrary "Debug"
Some debugging functions.
label_on_each_bar(txt, y_position, label_size, label_color, txt_color)
Prints a label on every bar to show text. By default, only the last 50 labels will be shown on the chart. You can increase this amount up to a maximum of 500 by using the max_labels_count parameter in your script’s indicator() or strategy() declaration statement.
Parameters:
txt (string) : New label text.
y_position (float) : New price of the label position.
label_size (string) : Possible values: size.auto, size.tiny, size.small, size.normal, size.large, size.huge. Optional. Default value is `size.small`.
label_color (color) : New label border and arrow color. Optional. Default value is `color.blue`.
txt_color (color) : New text color. Optional. Default value is `color.white`.
Returns: void
label_on_last_bar(txt, y_position, label_size, label_color, txt_color, txt_align)
Prints one label at last bar to show text.
Parameters:
txt (string) : New label text.
y_position (float) : New price of the label position.
label_size (string) : Possible values: size.auto, size.tiny, size.small, size.normal, size.large, size.huge. Optional. Default value is `size.large`.
label_color (color) : New label border and arrow color. Optional. Default value is `color.blue`.
txt_color (color) : New text color. Optional. Default value is `color.white`.
txt_align (string) : Label text alignment. Optional. Possible values: text.align_left, text.align_center, text.align_right. Default value is `text.align_center`.
Returns: void
table_symbol_informations(table_position, table_color, text_color)
Prints a table to show all the Symbol information, including its function names.
Parameters:
table_position (string) : Position of the table. Optional. Possible values are: position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right. Default value is `position.middle_right`.
table_color (color) : The background color of the table. Optional. The default is `color.yellow`.
text_color (color) : The color of the text. Optional. The default is `color.black`.
Returns: void
table_array_float(array_float, table_columns, table_rows, table_position, table_color, txt_color, txt_size)
Prints a table to show float values of an array.
Parameters:
array_float (float ) : The array that will be showed.
table_columns (int)
table_rows (int) : The number of rows to show the values.
table_position (string) : Position of the table. Optional. Possible values are: position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right. Default value is `position.bottom_center`.
table_color (color) : The background color of the table. Optional. By default there is no color.
txt_color (color)
txt_size (string) : Possible values: size.auto, size.tiny, size.small, size.normal, size.large, size.huge. Optional. Default value is `size.normal`.
Returns: void
table_array_int(array_float, table_columns, table_rows, table_position, table_color, txt_color, txt_size)
Prints a table to show int values of an array.
Parameters:
array_float (int ) : The array that will be showed.
table_columns (int)
table_rows (int) : The number of rows to show the values.
table_position (string) : Position of the table. Optional. Possible values are: position.top_left, position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right, position.bottom_left, position.bottom_center, position.bottom_right. Default value is `position.bottom_center`.
table_color (color) : The background color of the table. Optional. By default there is no color.
txt_color (color)
txt_size (string) : Possible values: size.auto, size.tiny, size.small, size.normal, size.large, size.huge. Optional. Default value is `size.normal`.
Returns: void
TooltipLibrary "Tooltip"
This library helps creating and managing nice looking data (key/value) tooltips that you can use for
labels. The tooltips data key/value will align automatically. It is optional to convert the data to a values only string too.
method addSpacesToKey(this)
Calculates the amount of spaces needed after the key to make it the key least 4 characters wide.
Namespace types: Data
Parameters:
this (Data) : (Data) The Data.
method addTabs(this, longestKeyLength)
Calculates the amount of tabs to be used.
Namespace types: Data
Parameters:
this (Data) : (Data) The Data.
longestKeyLength (int)
method longestKeyLength(this)
Returns the length of the longest key string in the array.
Namespace types: Data
Parameters:
this (Data ) : (Tooltip) The object to work with.
@return (int) The length of the key.
method toString(tooltips, withKey)
Helper function for the tooltip.
Namespace types: Data
Parameters:
tooltips (Data )
withKey (bool) : (bool) Wether to create a string with keys in it.
@return (string) The string
new()
Creates a new array to store tooltip data in
@return (Data) The data array.
Data
Key/Value pair for tooltips
Fields:
key (series string)
value (series string)
MyVolatilityBandsLibrary "MyVolatilityBands"
Just a lil' library of volatility bands that I use in some scripts
bollingerbands(src, lkbk, mult, basis)
Bollinger Bands
Parameters:
src (float) : float
lkbk (int) : int
mult (float) : float
basis (float)
Returns: Bollinger Bands
donchianchannels(src, lkbk, band_width)
Donchian Channels
Parameters:
src (float) : float
lkbk (int) : int
band_width (float) : float
Returns: Donchian Channels with an outer band of varying thickness adjusted by the band_width input
doublehalfdonchianchannels(src, lkbk, divisor)
Double Half Donchian Channels
Parameters:
src (float) : float
lkbk (int) : int
divisor (float) : float
Returns: two adjustable bases calculated using Donchian Channels calculation that act as a measure of volatility
PivotLibrary "Pivot"
This library helps you store and manage pivots.
bias(isHigh, isHigher, prevWasHigher)
Helper function to calculate bias.
Parameters:
isHigh (bool) : (bool) Wether the pivot is a pivot high or not.
isHigher (bool) : (bool) Wether the pivot is a higher pivot or not.
@return (bool) The bias (true = bullish, false = bearish, na = neutral).
prevWasHigher (bool)
biasToString(bias)
Parameters:
bias (bool)
biasToColor(bias, theme)
Parameters:
bias (bool)
theme (Theme)
nameString(isHigh, isHigher)
Parameters:
isHigh (bool)
isHigher (bool)
abbrString(isHigh, isHigher)
Parameters:
isHigh (bool)
isHigher (bool)
tooltipString(y, isHigh, isHigher, bias, theme)
Parameters:
y (float)
isHigh (bool)
isHigher (bool)
bias (bool)
theme (Theme)
createLabel(x, y, isHigh, isHigher, prevWasHigher, settings)
Parameters:
x (int)
y (float)
isHigh (bool)
isHigher (bool)
prevWasHigher (bool)
settings (Settings)
new(x, y, isHigh, isHigher, settings)
Parameters:
x (int)
y (float)
isHigh (bool)
isHigher (bool)
settings (Settings)
newArray(size, initialValue)
Parameters:
size (int)
initialValue (Pivot)
method getFirst(this)
Namespace types: Pivot
Parameters:
this (Pivot )
method getLast(this, isHigh)
Namespace types: Pivot
Parameters:
this (Pivot )
isHigh (bool)
method getLastHigh(this)
Namespace types: Pivot
Parameters:
this (Pivot )
method getLastLow(this)
Namespace types: Pivot
Parameters:
this (Pivot )
method getPrev(this, numBack, isHigh)
Namespace types: Pivot
Parameters:
this (Pivot )
numBack (int)
isHigh (bool)
method getPrevHigh(this, numBack)
Namespace types: Pivot
Parameters:
this (Pivot )
numBack (int)
method getPrevLow(this, numBack)
Namespace types: Pivot
Parameters:
this (Pivot )
numBack (int)
method getText(this)
Namespace types: Pivot
Parameters:
this (Pivot)
method setX(this, value)
Namespace types: Pivot
Parameters:
this (Pivot)
value (int)
method setY(this, value)
Namespace types: Pivot
Parameters:
this (Pivot)
value (float)
method setXY(this, x, y)
Namespace types: Pivot
Parameters:
this (Pivot)
x (int)
y (float)
method setBias(this, value)
Namespace types: Pivot
Parameters:
this (Pivot)
value (int)
method setColor(this, value)
Namespace types: Pivot
Parameters:
this (Pivot)
value (color)
method setText(this, value)
Namespace types: Pivot
Parameters:
this (Pivot)
value (string)
method add(this, pivot)
Namespace types: Pivot
Parameters:
this (Pivot )
pivot (Pivot)
method updateLast(this, y, settings)
Namespace types: Pivot
Parameters:
this (Pivot )
y (float)
settings (Settings)
method update(this, y, isHigh, settings)
Namespace types: Pivot
Parameters:
this (Pivot )
y (float)
isHigh (bool)
settings (Settings)
Pivot
Stores Pivot data.
Fields:
x (series int)
y (series float)
isHigh (series bool)
isHigher (series bool)
bias (series bool)
lb (series label)
Theme
Attributes for customizable look and feel.
Fields:
size (series string)
colorDefault (series color)
colorNeutral (series color)
colorBullish (series color)
colorBearish (series color)
colored (series bool)
showTooltips (series bool)
showTooltipName (series bool)
showTooltipValue (series bool)
showTooltipBias (series bool)
Settings
All settings for the pivot.
Fields:
theme (Theme)
LYGLibraryLibrary "LYGLibrary"
A collection of custom tools & utility functions commonly used with my scripts
getDecimals()
Calculates how many decimals are on the quote price of the current market
Returns: The current decimal places on the market quote price
truncate(number, decimalPlaces)
Truncates (cuts) excess decimal places
Parameters:
number (float)
decimalPlaces (simple float)
Returns: The given number truncated to the given decimalPlaces
toWhole(number)
Converts pips into whole numbers
Parameters:
number (float)
Returns: The converted number
toPips(number)
Converts whole numbers back into pips
Parameters:
number (float)
Returns: The converted number
getPctChange(value1, value2, lookback)
Gets the percentage change between 2 float values over a given lookback period
Parameters:
value1 (float)
value2 (float)
lookback (int)
av_getPositionSize(balance, risk, stopPoints, conversionRate)
Calculates OANDA forex position size for AutoView based on the given parameters
Parameters:
balance (float)
risk (float)
stopPoints (float)
conversionRate (float)
Returns: The calculated position size (in units - only compatible with OANDA)
bullFib(priceLow, priceHigh, fibRatio)
Calculates a bullish fibonacci value
Parameters:
priceLow (float) : The lowest price point
priceHigh (float) : The highest price point
fibRatio (float) : The fibonacci % ratio to calculate
Returns: The fibonacci value of the given ratio between the two price points
bearFib(priceLow, priceHigh, fibRatio)
Calculates a bearish fibonacci value
Parameters:
priceLow (float) : The lowest price point
priceHigh (float) : The highest price point
fibRatio (float) : The fibonacci % ratio to calculate
Returns: The fibonacci value of the given ratio between the two price points
getMA(length, maType)
Gets a Moving Average based on type (MUST BE CALLED ON EVERY CALCULATION)
Parameters:
length (simple int)
maType (string)
Returns: A moving average with the given parameters
getEAP(atr)
Performs EAP stop loss size calculation (eg. ATR >= 20.0 and ATR < 30, returns 20)
Parameters:
atr (float)
Returns: The EAP SL converted ATR size
getEAP2(atr)
Performs secondary EAP stop loss size calculation (eg. ATR < 40, add 5 pips, ATR between 40-50, add 10 pips etc)
Parameters:
atr (float)
Returns: The EAP SL converted ATR size
barsAboveMA(lookback, ma)
Counts how many candles are above the MA
Parameters:
lookback (int)
ma (float)
Returns: The bar count of how many recent bars are above the MA
barsBelowMA(lookback, ma)
Counts how many candles are below the MA
Parameters:
lookback (int)
ma (float)
Returns: The bar count of how many recent bars are below the EMA
barsCrossedMA(lookback, ma)
Counts how many times the EMA was crossed recently
Parameters:
lookback (int)
ma (float)
Returns: The bar count of how many times price recently crossed the EMA
getPullbackBarCount(lookback, direction)
Counts how many green & red bars have printed recently (ie. pullback count)
Parameters:
lookback (int)
direction (int)
Returns: The bar count of how many candles have retraced over the given lookback & direction
getBodySize()
Gets the current candle's body size (in POINTS, divide by 10 to get pips)
Returns: The current candle's body size in POINTS
getTopWickSize()
Gets the current candle's top wick size (in POINTS, divide by 10 to get pips)
Returns: The current candle's top wick size in POINTS
getBottomWickSize()
Gets the current candle's bottom wick size (in POINTS, divide by 10 to get pips)
Returns: The current candle's bottom wick size in POINTS
getBodyPercent()
Gets the current candle's body size as a percentage of its entire size including its wicks
Returns: The current candle's body size percentage
isHammer(fib, colorMatch)
Checks if the current bar is a hammer candle based on the given parameters
Parameters:
fib (float)
colorMatch (bool)
Returns: A boolean - true if the current bar matches the requirements of a hammer candle
isStar(fib, colorMatch)
Checks if the current bar is a shooting star candle based on the given parameters
Parameters:
fib (float)
colorMatch (bool)
Returns: A boolean - true if the current bar matches the requirements of a shooting star candle
isDoji(wickSize, bodySize)
Checks if the current bar is a doji candle based on the given parameters
Parameters:
wickSize (float)
bodySize (float)
Returns: A boolean - true if the current bar matches the requirements of a doji candle
isBullishEC(allowance, rejectionWickSize, engulfWick)
Checks if the current bar is a bullish engulfing candle
Parameters:
allowance (float)
rejectionWickSize (float)
engulfWick (bool)
Returns: A boolean - true if the current bar matches the requirements of a bullish engulfing candle
isBearishEC(allowance, rejectionWickSize, engulfWick)
Checks if the current bar is a bearish engulfing candle
Parameters:
allowance (float)
rejectionWickSize (float)
engulfWick (bool)
Returns: A boolean - true if the current bar matches the requirements of a bearish engulfing candle
isInsideBar()
Detects inside bars
Returns: Returns true if the current bar is an inside bar
isOutsideBar()
Detects outside bars
Returns: Returns true if the current bar is an outside bar
barInSession(sess, useFilter)
Determines if the current price bar falls inside the specified session
Parameters:
sess (simple string)
useFilter (bool)
Returns: A boolean - true if the current bar falls within the given time session
barOutSession(sess, useFilter)
Determines if the current price bar falls outside the specified session
Parameters:
sess (simple string)
useFilter (bool)
Returns: A boolean - true if the current bar falls outside the given time session
dateFilter(startTime, endTime)
Determines if this bar's time falls within date filter range
Parameters:
startTime (int)
endTime (int)
Returns: A boolean - true if the current bar falls within the given dates
dayFilter(monday, tuesday, wednesday, thursday, friday, saturday, sunday)
Checks if the current bar's day is in the list of given days to analyze
Parameters:
monday (bool)
tuesday (bool)
wednesday (bool)
thursday (bool)
friday (bool)
saturday (bool)
sunday (bool)
Returns: A boolean - true if the current bar's day is one of the given days
atrFilter(atrValue, maxSize)
Parameters:
atrValue (float)
maxSize (float)
fillCell(tableID, column, row, title, value, bgcolor, txtcolor)
This updates the given table's cell with the given values
Parameters:
tableID (table)
column (int)
row (int)
title (string)
value (string)
bgcolor (color)
txtcolor (color)
Returns: A boolean - true if the current bar falls within the given dates
Mizar_LibraryThe "Mizar_Library" is a powerful tool designed for Pine Script™ programmer’s, providing a collection of general functions that facilitate the usage of Mizar’s DCA (Dollar-Cost-Averaging) bot system.
To begin using the Mizar Library, you first need to import it into your indicator script. Insert the following line below your indicator initiation line: import Mizar_Trading/Mizar_Library/1 as mizar (mizar is the chosen alias).
In the import statement, Mizar_Trading.Mizar_Library_v1 refers to the specific version of the Mizar Library you wish to use. Feel free to modify mizar to your preferred alias name.
Once the library is imported, you can leverage its functions by prefixing them with mizar. . This will prompt auto-completion suggestions displaying all the available user-defined functions provided by the Mizar Library.
Now, let's delve into some of the key functions available in the Mizar Library:
DCA_bot_msg(_cmd)
The DCA_bot_msg function accepts an user-defined type (UDT) _cmd as a parameter and returns a string with the complete JSON command for a Mizar DCA bot.
Parameters:
_cmd (bot_params) : ::: User-defined type (UDT) that holds all the necessary information for the bot command.
Returns: A string with the complete JSON command for a Mizar DCA bot.
rounding_to_ticks(value, ticks, rounding_type)
The rounding_to_ticks function rounds a calculated price to the nearest actual price based on the specified tick size.
Parameters:
value (float) : ::: The calculated price as float type, to be rounded to the nearest real price.
ticks (float) : ::: The smallest possible price obtained through a request in your script.
rounding_type (int) : ::: The rounding type for the price: 0 = closest real price, 1 = closest real price above, 2 = closest real price below.
Returns: A float value representing the rounded price to the next tick.
bot_params
Bot_params is an user-defined type (UDT) that represents the parameters required for a Mizar DCA bot.
Fields:
bot_id (series string) : The ID number of your Mizar DCA bot.
api_key (series string) : Your private API key from your Mizar account (keep it confidential!).
action (series string) : The command to perform: "open" (standard) or "close" optional .
tp_perc (series string) : The take profit percentage in decimal form (1% = "0.01") optional .
base_asset (series string) : The cryptocurrency you want to buy (e.g., "BTC").
quote_asset (series string) : The coin or fiat currency used for payment (e.g., "USDT" is standard if not specified) optional .
direction (series string) : The direction of the position: "long" or "short" (only applicable for two-way hedge bots) optional .
To obtain the JSON command string for the alert_function call, you can use the DCA_bot_msg function provided by the library. Simply pass the cmd_msg UDT as an argument and assign the returned string value to a variable.
Here's an example to illustrate the process:
// Import of the Mizar Library to use the included functions
import/Mizar_Trading/Mizar_Library/1 as mizar
// Example to set a variable called “cmd_msg” and all of its parameters
cmd_msg = mizar.bot_params. new()
cmd_msg.action := "open"
cmd_msg.api_key := "top secret"
cmd_msg.bot_id := "9999"
cmd_msg.base_asset := "BTC"
cmd_msg.quote_asset := "USDT"
cmd_msg.direction := "long"
cmd_msg.tp_perc := "0.015"
// Calling the Mizar conversion function named “DCA_bot_msg()” with the cmd_msg as argument to receive the JSON command and save it in a string variable called “alert_msg”
alert_msg = mizar.DCA_bot_msg(cmd_msg)
Feel free to utilize (series) string variables instead of constant strings. By incorporating the Mizar Library into your Pine Script, you gain access to a powerful set of functions and can leverage them according to your specific requirements.
For additional help or support, you can join the Mizar Discord channel. There, you'll find a dedicated Pine Script channel where you can ask any questions related to Pine Script.
MyMovingAveragesLibraryLibrary "MyMovingAveragesLibrary"
alma(src, lkbk, alma_offset, alma_sigma)
ALMA - Arnaud Legoux Moving Average
Parameters:
src (float) : float
lkbk (int) : int
alma_offset (simple float)
alma_sigma (simple float) : float
Returns: moving average
frama(src, lkbk, FC, SC)
FRAMA - Fractal Adaptive Moving Average
Parameters:
src (float) : float
lkbk (int) : int
FC (int) : int
SC (int) : int
Returns: moving average
kama(src, lkbk, kamafastend, kamaslowend)
KAMA - Kaufman Adaptive Moving Average
Parameters:
src (float) : float
lkbk (int) : int
kamafastend (int) : int
kamaslowend (int) : int
Returns: moving average
ema(src, lkbk)
EMA - Exponential Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
dema(src, lkbk)
DEMA - Double Exponential Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
tema(src, lkbk)
TEMA - Triple Exponential Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
hma(src, lkbk)
HMA - Hull Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
jma(src, lkbk, jurik_power, jurik_phase)
JMA - Jurik Moving Average
Parameters:
src (float) : float
lkbk (int) : int
jurik_power (int)
jurik_phase (float)
Returns: moving average
laguerre(src, alpha)
Laguerre Filter
Parameters:
src (float) : float
alpha (float) : float
Returns: moving average
lsma(src, lkbk, lsma_offset)
LSMA - Least Squares Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
lsma_offset (simple int) : int
Returns: moving average
mcginley(src, lkbk)
McGinley Dynamic
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
mf(src, lkbk, mf_feedback, mf_beta, mf_z)
Modular Filter
Parameters:
src (float) : float
lkbk (int) : int
mf_feedback (bool) : float
mf_beta (float) : boolean
mf_z (float) : float
Returns: moving average
rdma(src)
RDMA - RexDog Moving Average (RDA, as he calls it)
Parameters:
src (float) : flot
Returns: moving average
sma(src, lkbk)
SMA - Simple Moving Average
Parameters:
src (float) : float
lkbk (int) : int
Returns: moving average
smma(src, lkbk)
SMMA - Smoothed Moving Average (known as RMA in TradingView)
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
t3(src, lkbk)
T3 Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
tma(src, lkbk)
TMA - Triangular Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
vama(src, lkbk, vol_lkbk)
VAMA - Volatility-Adjusted Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
vol_lkbk (int) : int
vwma(src, lkbk)
VWMA - Volume-Weighted Moving Average
Parameters:
src (float) : float
lkbk (simple int) : int
Returns: moving average
mf_zlagma(src, lkbk)
Zero-Lag Moving Average
Parameters:
src (float) : float
lkbk (int) : int
Returns: moving average
Absolute ZigZag LibLibrary "Absolute_ZigZag_Lib"
This ZigZag Library is a Bit different. Instead of using percentages or looking more than 1 bar left or right, this Zigzag library calculates pivots by just looking at the current bar highs and lows and the ones of one bar earlier.
This is the most accurate way of calculating pivots and it also eliminates lag.
The library also features a solution for bars that have both a higher high and a higher low like seen below.
You can also use your own colors for the labels and the lines.
You can also quickly select a one-colored theme without changing all colors at once
method isHigherHigh(this)
Checks if current pivot is a higher high
Namespace types: Pivot
Parameters:
this (Pivot) : (Pivot) The object to work with.
@return (bool) True if the pivot is a higher high, false if not.
method isLowerHigh(this)
Checks if current pivot is a lower high
Namespace types: Pivot
Parameters:
this (Pivot) : (Pivot) The object to work with.
@return (bool) True if the pivot is a lower high, false if not.
method isHigherLow(this)
Checks if current pivot is a higher low
Namespace types: Pivot
Parameters:
this (Pivot) : (Pivot) The object to work with.
@return (bool) True if the pivot is a higher low, false if not.
method isLowerLow(this)
Checks if current pivot is a lower low
Namespace types: Pivot
Parameters:
this (Pivot) : (Pivot) The object to work with.
@return (bool) True if the pivot is a lower low, false if not.
method getLastPivotHigh(this)
Gets the last Pivot High
Namespace types: Pivot
Parameters:
this (Pivot ) : (array) The object to work with.
@return (Pivot) The latest Pivot High
method getLastPivotLow(this)
Gets the last Pivot Low
Namespace types: Pivot
Parameters:
this (Pivot ) : (array) The object to work with.
@return (Pivot) The latest Pivot Low
method prev(this, index)
Namespace types: Pivot
Parameters:
this (Pivot )
index (int)
method last(this, throwError)
Namespace types: Pivot
Parameters:
this (Pivot )
throwError (bool)
new(highFirst, theme)
Parameters:
highFirst (bool)
theme (Theme)
getLowerTimeframePeriod()
Theme
Used to create a (color) theme to draw Zigzag
Fields:
colorDefault (series color)
colorNeutral (series color)
colorBullish (series color)
colorBearish (series color)
coloredLines (series bool)
Point
Used to determine a coordination on the chart
Fields:
x (series int)
y (series float)
Pivot
Used to determine pivots on the chart
Fields:
point (Point)
isHigh (series bool)
isHigher (series bool)
ln (series line)
lb (series label)
GeneratorBetaLib:Generator
This library generate levels that could be used inside SNG scripts and strategies. Also uses beta version of SNG Types library
IndicatorsLibrary "Indicators"
this has a calculation for the most used indicators.
macd4C(fastMa, slowMa)
this calculates macd 4c
Parameters:
fastMa (simple int) : is the period for the fast ma. the minimum value is 7
slowMa (simple int) : is the period for the slow ma. the minimum value is 7
Returns: the macd 4c value for the current bar
rsi(rsiSourceInput, rsiLengthInput)
this calculates rsi
Parameters:
rsiSourceInput (float) : is the source for the rsi
rsiLengthInput (simple int) : is the period for the rsi
Returns: the rsi value for the current bar
ao(source, fastPeriod, slowPeriod)
this calculates ao
Parameters:
source (float) : is the source for the ao
fastPeriod (int) : is the period for the fast ma
slowPeriod (int) : is the period for the slow ma
Returns: the ao value for the current bar
kernelAoOscillator(kernelFastLookback, kernelSlowLookback, kernelFastWeight, kernelSlowWeight, kernelFastRegressionStart, kernelSlowRegressionStart, kernelFastSmoothPeriod, kernelSlowSmoothPeriod, kernelFastSmooth, kernelSlowSmooth, source)
this calculates our own kernel ao oscillator which we made
Parameters:
kernelFastLookback (simple int)
kernelSlowLookback (simple int)
kernelFastWeight (simple float)
kernelSlowWeight (simple float)
kernelFastRegressionStart (simple int)
kernelSlowRegressionStart (simple int)
kernelFastSmoothPeriod (int)
kernelSlowSmoothPeriod (int)
kernelFastSmooth (bool)
kernelSlowSmooth (bool)
source (float) : is the source for the ao
Returns: the kernel ao oscillator value for the current bar, the colors for both the fast and slow kernel, the fast & slow kernel
signalLineKernel(lag, h, r, x_0, smoothColors, _src, c_bullish, c_bearish)
Parameters:
lag (int)
h (float)
r (float)
x_0 (int)
smoothColors (bool)
_src (float)
c_bullish (color)
c_bearish (color)
zigzagCalc(Depth, Deviation, Backstep, repaint, Show_zz, line_thick, text_color)
Parameters:
Depth (int)
Deviation (int)
Backstep (int)
repaint (bool)
Show_zz (bool)
line_thick (int)
text_color (color)
RelativeValue█ OVERVIEW
This library is a Pine Script™ programmer's tool offering the ability to compute relative values, which represent comparisons of current data points, such as volume, price, or custom indicators, with their analogous historical data points from corresponding time offsets. This approach can provide insightful perspectives into the intricate dynamics of relative market behavior over time.
█ CONCEPTS
Relative values
In this library, a relative value is a metric that compares a current data point in a time interval to an average of data points with corresponding time offsets across historical periods. Its purpose is to assess the significance of a value by considering the historical context within past time intervals.
For instance, suppose we wanted to calculate relative volume on an hourly chart over five daily periods, and the last chart bar is two hours into the current trading day. In this case, we would compare the current volume to the average of volume in the second hour of trading across five days. We obtain the relative volume value by dividing the current volume by this average.
This form of analysis rests on the hypothesis that substantial discrepancies or aberrations in present market activity relative to historical time intervals might help indicate upcoming changes in market trends.
Cumulative and non-cumulative values
In the context of this library, a cumulative value refers to the cumulative sum of a series since the last occurrence of a specific condition (referred to as `anchor` in the function definitions). Given that relative values depend on time, we use time-based conditions such as the onset of a new hour, day, etc. On the other hand, a non-cumulative value is simply the series value at a specific time without accumulation.
Calculating relative values
Four main functions coordinate together to compute the relative values: `maintainArray()`, `calcAverageByTime()`, `calcCumulativeSeries()`, and `averageAtTime()`. These functions are underpinned by a `collectedData` user-defined type (UDT), which stores data collected since the last reset of the timeframe along with their corresponding timestamps. The relative values are calculated using the following procedure:
1. The `averageAtTime()` function invokes the process leveraging all four of the methods and acts as the main driver of the calculations. For each bar, this function adds the current bar's source and corresponding time value to a `collectedData` object.
2. Within the `averageAtTime()` function, the `maintainArray()` function is called at the start of each anchor period. It adds a new `collectedData` object to the array and ensures the array size does not exceed the predefined `maxSize` by removing the oldest element when necessary. This method plays an essential role in limiting memory usage and ensuring only relevant data over the desired number of periods is in the calculation window.
3. Next, the `calcAverageByTime()` function calculates the average value of elements within the `data` field for each `collectedData` object that corresponds to the same time offset from each anchor condition. This method accounts for cases where the current index of a `collectedData` object exceeds the last index of any past objects by using the last available values instead.
4. For cumulative calculations, the `averageAtTime()` function utilizes the `isCumulative` boolean parameter. If true, the `calcCumulativeSeries()` function will track the running total of the source data from the last bar where the anchor condition was met, providing a cumulative sum of the source values from one anchor point to the next.
To summarize, the `averageAtTime()` function continually stores values with their corresponding times in a `collectedData` object for each bar in the anchor period. When the anchor resets, this object is added to a larger array. The array's size is limited by the specified number of periods to be averaged. To correlate data across these periods, time indexing is employed, enabling the function to compare corresponding points across multiple periods.
█ USING THIS LIBRARY
The library simplifies the complex process of calculating relative values through its intuitive functions. Follow the steps below to use this library in your scripts.
Step 1: Import the library and declare inputs
Import the library and declare variables based on the user's input. These can include the timeframe for each period, the number of time intervals to include in the average, and whether the calculation uses cumulative values. For example:
//@version=5
import TradingView/RelativeValue/1 as TVrv
indicator("Relative Range Demo")
string resetTimeInput = input.timeframe("D")
int lengthInput = input.int(5, "No. of periods")
Step 2: Define the anchor condition
With these inputs declared, create a condition to define the start of a new period (anchor). For this, we use the change in the time value from the input timeframe:
bool anchor = timeframe.change(resetTimeInput)
Step 3: Calculate the average
At this point, one can calculate the average of a value's history at the time offset from the anchor over a number of periods using the `averageAtTime()` function. In this example, we use True Range (TR) as the `source` and set `isCumulative` to false:
float pastRange = TVrv.averageAtTime(ta.tr, lengthInput, anchor, false)
Step 4: Display the data
You can visualize the results by plotting the returned series. These lines display the non-cumulative TR alongside the average value over `lengthInput` periods for relative comparison:
plot(pastRange, "Past True Range Avg", color.new(chart.bg_color, 70), 1, plot.style_columns)
plot(ta.tr, "True Range", close >= open ? color.new(color.teal, 50) : color.new(color.red, 50), 1, plot.style_columns)
This example will display two overlapping series of columns. The green and red columns depict the current TR on each bar, and the light gray columns show the average over a defined number of periods, e.g., the default inputs on an hourly chart will show the average value at the hour over the past five days. This comparative analysis aids in determining whether the range of a bar aligns with its typical historical values or if it's an outlier.
█ NOTES
• The foundational concept of this library was derived from our initial Relative Volume at Time script. This library's logic significantly boosts its performance. Keep an eye out for a forthcoming updated version of the indicator. The demonstration code included in the library emulates a streamlined version of the indicator utilizing the library functions.
• Key efficiencies in the data management are realized through array.binary_search_leftmost() , which offers a performance improvement in comparison to its loop-dependent counterpart.
• This library's architecture utilizes user-defined types (UDTs) to create custom objects which are the equivalent of variables containing multiple parts, each able to hold independent values of different types . The recently added feature was announced in this blog post.
• To enhance readability, the code substitutes array functions with equivalent methods .
Look first. Then leap.
█ FUNCTIONS
This library contains the following functions:
calcCumulativeSeries(source, anchor)
Calculates the cumulative sum of `source` since the last bar where `anchor` was `true`.
Parameters:
source (series float) : Source used for the calculation.
anchor (series bool) : The condition that triggers the reset of the calculation. The calculation is reset when `anchor` evaluates to `true`, and continues using the values accumulated since the previous reset when `anchor` is `false`.
Returns: (float) The cumulative sum of `source`.
averageAtTime(source, length, anchor, isCumulative)
Calculates the average of all `source` values that share the same time difference from the `anchor` as the current bar for the most recent `length` bars.
Parameters:
source (series float) : Source used for the calculation.
length (simple int) : The number of reset periods to consider for the average calculation of historical data.
anchor (series bool) : The condition that triggers the reset of the average calculation. The calculation is reset when `anchor` evaluates to `true`, and continues using the values accumulated since the previous reset when `anchor` is `false`.
isCumulative (simple bool) : If `true`, `source` values are accumulated until the next time `anchor` is `true`. Optional. The default is `true`.
Returns: (float) The average of the source series at the specified time difference.
AoDivergenceLibrary_Library "AoDivergenceLibrary_"
this has functions which calculate and plot divergences which are used for ao divergences. essentially, this finds divergences by using the ao divergence logic. this logic has been used in "AO Hid & Reg Div with LC & Kernel".
regBullDivergence(swingLow, osc, colour)
Parameters:
swingLow (bool)
osc (float)
colour (color)
regBearDivergence(swingHigh, osc, colour)
Parameters:
swingHigh (bool)
osc (float)
colour (color)
hidBullDivergence(swingHigh, osc, colour)
Parameters:
swingHigh (bool)
osc (float)
colour (color)
hidBearDivergence(swingHigh, osc, colour)
Parameters:
swingHigh (bool)
osc (float)
colour (color)
.print()
You don't need to initialize anything..
After you import the library you can use .print() as easy as that..!
Hope this helps
* use a unique ID for each .print() call
let me know if you run into any bugs
by trying to make it as user friendly as possible i had to do
some not ideal things so there's a chance it could present some bugs with
a lot of labels present on the chart
and if you use label.all to parse and manipulate the labels on the chart..
most likely it will cause an issue but not a lot of people use this so
I don't think that will be a problem.
thanks,
FFriZz | frizlabz
Library "print"
Single function to print any type to console
method str(inp)
`method` convert all types to string
```
(overload)
*.str(any inp) => string
```
Namespace types: series string, simple string, input string, const string
Parameters:
inp (string) : `any` - desc | Required
Returns: `string` formatted string
method str(inp)
Namespace types: series int, simple int, input int, const int
Parameters:
inp (int)
method str(inp)
Namespace types: series float, simple float, input float, const float
Parameters:
inp (float)
method str(inp)
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
inp (bool)
method str(inp)
Namespace types: series linefill
Parameters:
inp (linefill)
method str(inp)
Namespace types: series line
Parameters:
inp (line)
method str(inp)
Namespace types: series box
Parameters:
inp (box)
method str(inp)
Namespace types: series label
Parameters:
inp (label)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: matrix
Parameters:
inp (matrix)
method str(inp)
Namespace types: linefill
Parameters:
inp (linefill )
method str(inp)
Namespace types: line
Parameters:
inp (line )
method str(inp)
Namespace types: box
Parameters:
inp (box )
method str(inp)
Namespace types: label
Parameters:
inp (label )
method str(inp)
Namespace types: string
Parameters:
inp (string )
method str(inp)
Namespace types: int
Parameters:
inp (int )
method str(inp)
Namespace types: float
Parameters:
inp (float )
method str(inp)
Namespace types: bool
Parameters:
inp (bool )
method arrayShorten(str)
arrayShorten
Namespace types: series string, simple string, input string, const string
Parameters:
str (string) : `string` - the string to shorten | Required
Returns: `string` - a shortened version of the input string if it is an array with more than 7 elements, otherwise the original string
method matrixShorten(str)
matrixShorten
Namespace types: series string, simple string, input string, const string
Parameters:
str (string) : `string` - the string to shorten | Required
Returns: `string` - the shortened matrix string if the input is a matrix, otherwise returns the input string as is
method print(x, ID)
print all types to theh same console with just this `method/function`
```
(overload)
*.print(any x, string ID, bool shorten=true?) => console
"param 'shorten' - only for arrays and matrixs" | true
```
Namespace types: series string, simple string, input string, const string
Parameters:
x (string) : - `any` input to convert
ID (string) : - `string` unique id for label on console `MUST BE UNIQUE`
Returns: adds the `ID` and the `inp` to the console on the chart
method print(x, ID)
Namespace types: series float, simple float, input float, const float
Parameters:
x (float)
ID (string)
method print(x, ID)
Namespace types: series int, simple int, input int, const int
Parameters:
x (int)
ID (string)
method print(x, ID)
Namespace types: series box
Parameters:
x (box)
ID (string)
method print(x, ID)
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
x (bool)
ID (string)
method print(x, ID)
Namespace types: series label
Parameters:
x (label)
ID (string)
method print(x, ID)
Namespace types: series line
Parameters:
x (line)
ID (string)
method print(x, ID)
Namespace types: series linefill
Parameters:
x (linefill)
ID (string)
method print(x, ID, shorten)
Namespace types: string
Parameters:
x (string )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: float
Parameters:
x (float )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: int
Parameters:
x (int )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: box
Parameters:
x (box )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: bool
Parameters:
x (bool )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: label
Parameters:
x (label )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: line
Parameters:
x (line )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: linefill
Parameters:
x (linefill )
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
method print(x, ID, shorten)
Namespace types: matrix
Parameters:
x (matrix)
ID (string)
shorten (bool)
DarkWaveColorThemesLibrary "DarkWaveColorThemes"
Description:
A simple, binary color-theming library that provides you with easy-access 'bullish and bearish' colors which you can use to make your indicators more aesthetically pleasing. These color themes were developed to help the community make indicators look excellent with ease.
Functions:
1. getThemeColor(themeName, colorType)
Description:
This function returns a color (either a 'Bullish' or 'Bearish' color, depending on your 'colorType' parameter input) according to the theme you have supplied as the 'themeName' parameter.
Parameters:
themeName (string) : Specify the theme you want to reference. Options include: 'DarkWave', 'Synthwave', 'DarkWave Crypto', 'Crystal Pool', 'Aquafarer', 'Mystic Armor', 'Futurist', 'Electric Zest', 'Stealth Ride', 'Long Trader', 'Short Trader', 'Emerald Glow', 'Gold Heist', 'Floral', 'Cobalt Twilight', and 'Sunrise'.
colorType (string) : Specify which color you want to reference from the theme. Options include: 'Bullish' and 'Bearish'.
Returns:
Your specified color type according to your specified theme.
LibraryTimeframeHelperLibrary "LibraryTimeframeHelper"
Helper functions to work with timeframes: to get the next higher TF, and to make the string pretty for use in labels. Perhaps I'll add more later.
f_getHigherTF(_TF)
f_getHigherTF(): Converts the input timeframe into the next one up in the list of commonly used timeframes. NOTE: You can NOT use a TF from this function as input to a request.security() call if called from this library because it gets converted to a series (since there's nothing special about this function, I expect this probably goes for any library). However, you CAN copy the code and use it directly in your script, in which case the output is only a simple variable and thus suitable for the timeframe of a request.security() call.
Parameters:
_TF (string) - The timeframe to convert.
Returns: : A string in standard timeframe format.
f_prettifyTF(_TF)
f_prettifyTF(): Converts the input timeframe from standard timeframe format to the format shown by TradingView on a chart. The output is not suitable for use as an input timeframe of a request.security() call.
Parameters:
_TF (string) - The timeframe to convert.
Returns: : A string in prettified timeframe format.
AlgebraLibLibrary "AlgebraLib"
f_signaldraw(_side, _date)
: Draw a simple label with Buy or Sell signal
Parameters:
_side (string)
_date (int)
Returns: : VOID, it draws a new label
cphelperLibrary "cphelper"
ACPU helper library - for private use. Not so meaningful for others.
calculate_rr(targetArray, rrArray, breakevenOnTarget1)
calculates risk reward for given targets
Parameters:
targetArray (float ) : array of targets
rrArray (float ) : array of risk reward
breakevenOnTarget1 (simple bool) : option to breakeven
Returns: array rrArray
trendPairs(l1StartX, l1StartY, l1EndX, l1EndY, l2StartX, l2StartY, l2EndX, l2EndY, zgColor)
creates trendline pairs
Parameters:
l1StartX (int) : startX of first line
l1StartY (float) : startY of first line
l1EndX (int) : endX of first line
l1EndY (float) : endY of first line
l2StartX (int) : startX of second line
l2StartY (float) : startY of second line
l2EndX (int) : endX of second line
l2EndY (float) : endY of second line
zgColor (color) : line color
Returns:
find_type(l1t, l2t, channelThreshold)
Finds type based on trendline pairs
Parameters:
l1t (line) : line1
l2t (line) : line2
channelThreshold (simple float) : theshold for channel identification
Returns: pattern type and flags
getFlags(flags)
Flatten flags
Parameters:
flags (bool ) : array of flags
Returns: - flattened flags isChannel, isTriangle, isWedge, isExpanding, isContracting, isFlat, isRising, isFalling
getType(typeNum)
Get type based on type number
Parameters:
typeNum (int) : number representing type
Returns: String value of type
getStatus(status, maxStatus)
Get status based on integer value representations
Parameters:
status (int) : integer representing current status
maxStatus (int) : integer representing max status
Returns: String status value
calculate_simple_targets(trendLines, settingsMatrix, patternTypeMapping, patternType)
Calculate targets based on trend lines
Parameters:
trendLines (line ) : trendline pair array
settingsMatrix (matrix) : matrix containing settings
patternTypeMapping (string ) : array containing pattern type mapping
patternType (int) : pattern type
Returns: arrays containing long and short calculated targets
recalculate_position(patternTypeAndStatusMatrix, targetMatrix, index, pIndex, status, maxStatus, targetValue, stopValue, dir, breakevenOnTarget1)
Recalculate position values
Parameters:
patternTypeAndStatusMatrix (matrix) : matrix containing pattern type and status
targetMatrix (matrix) : matrix containing targets
index (int) : current index
pIndex (int) : pattern index
status (int) : current status
maxStatus (int) : max status reached
targetValue (float) : current target value
stopValue (float) : current stop value
dir (int) : direction
breakevenOnTarget1 (simple bool) : flag to breakeven upon target1
Returns: new status and maxStatus values
draw_targets(longTargets, shortTargets, index, labelColor, patternName, positionIndex, longMaxStatus, longStatus, shortMaxStatus, shortStatus, tempBoxes, tempLines, tempLabels)
Draw targets on chart
Parameters:
longTargets (matrix) : matrix containing long targets
shortTargets (matrix) : matrix containing short targets
index (int) : current index
labelColor (color) : color of lines and labels
patternName (string) : Pattern name
positionIndex (int) : position on the chart
longMaxStatus (int) : max status for long
longStatus (int) : long status value
shortMaxStatus (int) : max status for short
shortStatus (int) : short status value
tempBoxes (box ) : temporary box array
tempLines (line ) : temporary lines array
tempLabels (label ) : temporary labels array
Returns: void
populate_open_stats(patternIdArray, barMatrix, patternTypeAndStatusMatrix, patternColorArray, longTargets, shortTargets, patternRRMatrix, OpenStatPosition, lblSizeOpenTrades)
Populate open stats table
Parameters:
patternIdArray (int ) : pattern Ids
barMatrix (matrix) : matrix containing bars
patternTypeAndStatusMatrix (matrix) : matrix containing pattern type and status
patternColorArray (color ) : array containing current patter colors
longTargets (matrix) : matrix of long targets
shortTargets (matrix) : matrix of short targets
patternRRMatrix (matrix) : pattern risk reward matrix
OpenStatPosition (simple string) : table position
lblSizeOpenTrades (simple string) : text size
Returns: void
draw_pattern_label(trendLines, patternFlagMatrix, patternTypeAndStatusMatrix, patternColorArray, patternFlags, patternLabelArray, zgColor, patternType, drawLabel, clearOldPatterns, safeRepaint, maxPatternsReference)
Parameters:
trendLines (line )
patternFlagMatrix (matrix)
patternTypeAndStatusMatrix (matrix)
patternColorArray (color )
patternFlags (bool )
patternLabelArray (label )
zgColor (color)
patternType (int)
drawLabel (simple bool)
clearOldPatterns (simple bool)
safeRepaint (simple bool)
maxPatternsReference (simple int)
populate_closed_stats(patternTypeAndStatusMatrix, bullishCounts, bearishCounts, bullishRetouchCounts, bearishRetouchCounts, bullishSizeMatrix, bearishSizeMatrix, bullishRR, bearishRR, ClosedStatsPosition, lblSizeClosedTrades, showSelectivePatternStats, showPatternStats, showStatsInPercentage)
Parameters:
patternTypeAndStatusMatrix (matrix)
bullishCounts (matrix)
bearishCounts (matrix)
bullishRetouchCounts (matrix)
bearishRetouchCounts (matrix)
bullishSizeMatrix (matrix)
bearishSizeMatrix (matrix)
bullishRR (matrix)
bearishRR (matrix)
ClosedStatsPosition (simple string)
lblSizeClosedTrades (simple string)
showSelectivePatternStats (simple bool)
showPatternStats (simple bool)
showStatsInPercentage (simple bool)