[Library] VAccThis is the library version of VAcc (Velocity & Acceleration), a momentum indicator published by Scott Cong in Stocks & Commodities V. 41:09 (8–15). It applies concepts from physics, namely velocity and acceleration, to financial markets. VAcc functions similarly to the popular MACD (Moving Average Convergence Divergence) indicator when using a longer lookback period, but produces more responsive results. With shorter periods, VAcc exhibits characteristics reminiscent of the stochastic oscillator.
The indicator version of this algorithm is linked below:
🟠 Algorithm
The average velocity over the past n periods is defined as
((C - C_n) / n + (C - C_{n-1}) / (n - 1) + … + (C - C_i) / i + (C - C_1) / 1) / n
At its core, the velocity is a weighted average of the rate of change over the past n periods.
The calculation of the acceleration follows a similar process, where it’s defined as
((V - V_n) / n + (V - V_{n - 1}) / (n - 1) + … + (V - V_i) / i + (V - V_1) / 1) / n
🟠 Comparison with MACD
A comparison of VAcc and MACD on the daily Nasdaq 100 (NDX) chart from August 2022 helps demonstrate VAcc's improved sensitivity. Both indicators utilized a lookback period of 26 days and smoothing of 9 periods.
The VAcc histogram clearly shows a divergence forming, with momentum weakening as prices reached new highs. In contrast, the corresponding MACD histogram significantly lagged in confirming the divergence, highlighting VAcc's ability to identify subtle shifts in trend momentum more immediately than the traditional MACD.
Techindicator
XLibrary "X"
a collection of 'special' methods/functions ('special' at the time of conception)
Initial functions includes:
• count of a given number in a given array
• array.get() but option added to use negative index
• sum of all digits until the output < 10
• slope/angle calculation of lines
method count_num_in_array(arr, num)
counts how many times a given number is present in a given array (0 when not present)
Namespace types: int
Parameters:
arr (int ) : Array (int, float )
num (int) : Number that needs to be counted (int, float)
Returns: count of number in array (0 when not present)
method count_num_in_array(arr, num)
Namespace types: float
Parameters:
arr (float )
num (float)
method get_(arr, idx)
array.get() but you can use negative index (-1 is last of array, -2 is second last,...)
Namespace types: int
Parameters:
arr (int ) : Array (int, float, string, bool, label, line, box, color )
idx (int) : Index
Returns: value/object at index, 'na' if index is outside array
method get_(arr, idx)
Namespace types: float
Parameters:
arr (float )
idx (int)
method get_(arr, idx)
Namespace types: string
Parameters:
arr (string )
idx (int)
method get_(arr, idx)
Namespace types: bool
Parameters:
arr (bool )
idx (int)
method get_(arr, idx)
Namespace types: label
Parameters:
arr (label )
idx (int)
method get_(arr, idx)
Namespace types: line
Parameters:
arr (line )
idx (int)
method get_(arr, idx)
Namespace types: box
Parameters:
arr (box )
idx (int)
method get_(arr, idx)
Namespace types: color
Parameters:
arr (color )
idx (int)
method sumAllNumbers_till_under_10(num)
sums all separate digit numbers, it repeats the process until sum < 10
Namespace types: series int, simple int, input int, const int
Parameters:
num (int) : Number (int, float)
Returns: value between 0 and 9
method sumAllNumbers_till_under_10(num)
Namespace types: series float, simple float, input float, const float
Parameters:
num (float)
method XYaxis(width)
Global function to calculate Yaxis, which is used in calculate_slope() method
Namespace types: series int, simple int, input int, const int
Parameters:
width (int) : Amount of bars for reference X-axis
Returns: Yaxis
method calculate_slope(width, XYratio, Yaxis, x1, y1, x2, y2)
Returns a normalised slope
Namespace types: series int, simple int, input int, const int
Parameters:
width (int) : Amount of bars to calculate height
XYratio (float) : Ratio to calculate height (from width) normalised_slope calculation
Yaxis (float) : Y-axis from XYaxis() method
x1 (int) : x1 of line
y1 (float) : y1 of line
x2 (int) : x2 of line
y2 (float) : y2 of line
Returns: Tuple of -> slope = price difference per bar
ZigLibLibrary "ZigLib"
Calculate the points for ZigZag++.
You can use custom data and resolution for your ZigZag++.
Sample Usage
import DevLucem/ZigLib/1 as ZigZag
= ZigZag.zigzag(low, high)
bgcolor(direction<0? color.rgb(255, 82, 82, 80): color.rgb(0, 230, 119, 80))
line zz = line.new(z1.time, z1.price, z2.time, z2.price, xloc.bar_time, width=3)
if direction==direction
line.delete(zz )
zigzag(_low, _high, depth, deviation, backstep)
Get current zigzag points and direction
Parameters:
_low (float)
_high (float)
depth (int)
deviation (int)
backstep (int)
Returns direction, chart point 1 and chart point 2
lib_retracement_patternsLibrary "lib_retracement_patterns"
types and functions for XABCD pattern detection and plotting
method set_tolerances(this, tolerance_Bmin, tolerance_Bmax, tolerance_Cmin, tolerance_Cmax, tolerance_Dmin, tolerance_Dmax)
sets tolerances for B, C and D retracements. This creates another Pattern instance that is set as tolerances field on the original and will be used for detection instead of the original ratios.
Namespace types: Pattern
create_config(pattern_line_args, pattern_point_args, name_label_args, retracement_line_args, retracement_label_args, line_args_Dtarget, line_args_completion, line_args_tp1, line_args_tp2, line_args_sl, label_args_completion, label_args_tp1, label_args_tp2, label_args_sl, label_terminal, label_terminal_up_char, label_terminal_down_char, color_bull, color_bear, color_muted, fill_opacity, draw_point_labels, draw_retracements, draw_target_range, draw_levels, hide_shorter_if_shared_legs_greater_than_max, hide_engulfed_pattern, hide_engulfed_pattern_of_same_type, hide_longer_pattern_with_same_X, mute_previous_pattern_when_next_overlaps, keep_failed_patterns)
method direction(this)
Namespace types: Match
method length(this)
return the length of this pattern, determined by the distance between X and D point
Namespace types: Match
method height(this)
return the height of this pattern, determined by the distance between the biggest distance between A/C and X/D
Namespace types: Match
method is_forming(this)
returns true if not complete, not expired and not invalidated
Namespace types: Match
method tostring(this)
return a string representation of all Matches in this map
Namespace types: Match
method tostring(this)
Namespace types: map
remove_complete_and_expired(this)
method add(this, item)
Namespace types: map
method is_engulfed_by(this, other)
checks if this Match is engulfed by the other
Namespace types: Match
method update(tracking_matches, zigzag, patterns, max_age_idx, detect_dir, pattern_minlen, pattern_maxlen, max_sub_waves, max_shared_legs, max_XB_BD_ratio, debug_log)
checks this map of tracking Matches if any of them was completed or invalidated in
Namespace types: map
method mute(this, mute_color, mute_fill_color)
mute this pattern by making it all one color (lines and labels, for pattern fill there's another)
Namespace types: Match
method mute(this, mute_color, mute_fill_color)
mute all patterns in this map by making it all one color (lines and labels, for pattern fill there's another)
Namespace types: map
method hide(this)
hide this pattern by muting it with a transparent color
Namespace types: Match
method reset_styles(this)
reset the style of a muted or hidden match back to the preset configuration
Namespace types: Match
method delete(this)
remove the plot of this Match from the chart
Namespace types: Match
method delete(this)
remove all the plots of the Matches in this map from the chart
Namespace types: map
method draw(this)
draw this Match on the chart
Namespace types: Match
method draw(this, config, all_patterns, debug_log)
draw all Matches in this map, considering all other patterns for engulfing and overlapping
Namespace types: map
method check_hide_or_mute(this, all, config, debug_log)
checks if this pattern needs to be hidden or muted based on other plotted patterns and given configuration
Namespace types: Match
method add_if(id, item, condition)
convenience function to add a search pattern to a list, only if given condition (input.bool) is true
Namespace types: Pattern
Pattern
type to hold retracement ratios and tolerances for this pattern, as well as targets for trades
Config
allows control of pattern plotting shape and colors, as well as settings for hiding overlapped patterns etc.
Match
holds all information on a Pattern and a successful match in the chart. Includes XABCD pivot points as well as all Line and Label objects to draw it
RationalQuadraticKernelFunctionDescription:
An optimised library for non-repainting Rational Quadratic Kernel Library. Added lookbackperiod and a validation to prevent division by zero.
Thanks to original author jdehorty.
Usage:
1. Import the library into your Pine Script code using the library function.
import vinayakavajiraya/RationalQuadraticKernelFunction/1
2. Call the Main Function:
Use the rationalQuadraticKernel function to calculate the Rational Quadratic Kernel estimate.
Provide the following parameters:
`_src` (series float): The input series of float values, typically representing price data.
`_lookback` (simple int): The lookback period for the kernel calculation (an integer).
`_relativeWeight` (simple float): The relative weight factor for the kernel (a float).
`startAtBar` (simple int): The bar index to start the calculation from (an integer).
rationalQuadraticEstimate = rationalQuadraticKernel(_src, _lookback, _relativeWeight, startAtBar)
3. Plot the Estimate:
Plot the resulting estimate on your TradingView chart using the plot function.
plot(rationalQuadraticEstimate, color = color.red, title = "Rational Quadratic Kernel Estimate")
Parameter Explanation:
`_src`: The input series of price data, such as 'close' or any other relevant data.
`_lookback`: The number of previous bars to consider when calculating the estimate. Higher values capture longer-term trends.
`_relativeWeight`: A factor that controls the importance of each data point in the calculation. A higher value emphasizes recent data.
`startAtBar`: The bar index from which the calculation begins.
Example Usage:
Here's an example of how to use the library to calculate and plot the Rational Quadratic Kernel estimate for the 'close' price series:
//@version=5
library("RationalQuadraticKernelFunctions", true)
rationalQuadraticEstimate = rationalQuadraticKernel(close, 11, 1, 24)
plot(rationalQuadraticEstimate, color = color.orange, title = "Rational Quadratic Kernel Estimate")
This example calculates the estimate for the 'close' price series, considers the previous 11 bars, assigns equal weight to all data points, and starts the calculation from the 24th bar. The result is plotted as an orange line on the chart.
Highly recommend to customize the parameters to suit your analysis needs and adapt the library to your trading strategies.
lib_retracement_labelLibrary "lib_retracement_label"
creates a retracement label between the origin and target of a retracement, updating it's position (via update + draw) when the target moves.
create_tooltip(name, min, max, tol_min, tol_max)
Parameters:
name (string)
min (float)
max (float)
tol_min (float)
tol_max (float)
method update(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel)
method create_retracement_label(this, move_endpoint, args, tooltip)
Creates a new RetracementLabel object.
Namespace types: D.Line
Parameters:
this (Line type from robbatt/lib_plot_objects/23)
move_endpoint (Point type from robbatt/lib_plot_objects/23)
args (LabelArgs type from robbatt/lib_plot_objects/23)
tooltip (string)
method create_retracement_label(this, move_end, args, tooltip)
Creates a new RetracementLabel object.
Namespace types: D.Line
Parameters:
this (Line type from robbatt/lib_plot_objects/23)
move_end (Pivot type from robbatt/lib_pivot/43)
args (LabelArgs type from robbatt/lib_plot_objects/23)
tooltip (string)
method enqueue(id, item, max)
Namespace types: RetracementLabel
Parameters:
id (RetracementLabel )
item (RetracementLabel)
max (int)
method draw(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel)
method draw(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel )
method delete(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel)
method delete(this)
Namespace types: RetracementLabel
Parameters:
this (RetracementLabel )
RetracementLabel
Fields:
move_endpoint (|robbatt/lib_plot_objects/23;Point|#OBJ)
center_label (|robbatt/lib_plot_objects/23;CenterLabel|#OBJ)
RSNPSDLibrary "RSNPSD"
EMA5(source, EMAlength, Smoothlength)
Parameters:
source (float)
EMAlength (simple int)
Smoothlength (simple int)
SLOPE(source, slopeDistance)
Parameters:
source (float)
slopeDistance (simple int)
print(txt)
Parameters:
txt (string)
Extended Moving Average (MA) LibraryThis Extended Moving Average Library is a sophisticated and comprehensive tool for traders seeking to expand their arsenal of moving averages for more nuanced and detailed technical analysis.
The library contains various types of moving averages, each with two versions - one that accepts a simple constant length parameter and another that accepts a series or changing length parameter.
This makes the library highly versatile and suitable for a wide range of strategies and trading styles.
Moving Averages Included:
Simple Moving Average (SMA): This is the most basic type of moving average. It calculates the average of a selected range of prices, typically closing prices, by the number of periods in that range.
Exponential Moving Average (EMA): This type of moving average gives more weight to the latest data and is thus more responsive to new price information. This can help traders to react faster to recent price changes.
Double Exponential Moving Average (DEMA): This is a composite of a single exponential moving average, a double exponential moving average, and an exponential moving average of a triple exponential moving average. It aims to eliminate lag, which is a key drawback of using moving averages.
Jurik Moving Average (JMA): This is a versatile and responsive moving average that can be adjusted for market speed. It is designed to stay balanced and responsive, regardless of how long or short it is.
Kaufman's Adaptive Moving Average (KAMA): This moving average is designed to account for market noise or volatility. KAMA will closely follow prices when the price swings are relatively small and the noise is low.
Smoothed Moving Average (SMMA): This type of moving average applies equal weighting to all observations and smooths out the data.
Triangular Moving Average (TMA): This is a double smoothed simple moving average, calculated by averaging the simple moving averages of a dataset.
True Strength Force (TSF): This is a moving average of the linear regression line, a statistical tool used to predict future values from past values.
Volume Moving Average (VMA): This is a simple moving average of a volume, which can help to identify trends in volume.
Volume Adjusted Moving Average (VAMA): This moving average adjusts for volume and can be more responsive to volume changes.
Zero Lag Exponential Moving Average (ZLEMA): This type of moving average aims to eliminate the lag in traditional EMAs, making it more responsive to recent price changes.
Selector: The selector function allows users to easily select and apply any of the moving averages included in the library inside their strategy.
This library provides a broad selection of moving averages to choose from, allowing you to experiment with different types and find the one that best suits your trading strategy.
By providing both simple and series versions for each moving average, this library offers great flexibility, enabling users to pass both constant and changing length parameters as needed.
merge_pinbar_modifiedLibrary "merge_pinbar"
Published by @dandrideng
Modified by @RpNm1337
merge_pinbar: merge bars and check whether the bar is a pinbar
merge_pinbar(period, max_bars)
merge_pinbar: merge bars and check whether the bar is a pinbar
Parameters:
period (simple int)
max_bars (simple int)
Returns: array:
A_Taders_Edge_LIBRARYLibrary "A_Taders_Edge_LIBRARY"
RCI(_rciLength, _close, _interval, _outerMostRangeOfOscillator)
- You will see me using this a lot. DEFINITELY my favorite oscillator to utilize for SO many different things from timing entries/exits to determining trends.
Parameters:
_rciLength (int)
_close (float)
_interval (int)
_outerMostRangeOfOscillator (int)
Returns: - Outputs a single RCI value that will between (-)_outerMostRangeOfOscillator to (+)_outerMostRangeOfOscillator
InvalidTID(_close, _showInvalidAssets, _securityTickerid, _invalidArray)
- This is to add a table on the right of your chart that prints all the TickerID's that were either not formulated correctly in the scripts input or that is not a valid symbol and should be changed.
Parameters:
_close (float)
_showInvalidAssets (simple bool)
_securityTickerid (string)
_invalidArray (string )
Returns: - Does NOT return a value but rather the table with the invalid TickerID's from the scripts input that need to be changed.
LabelLocation(_firstLocation)
- This is ONLY for when you are wanting to print ALERT LABELS with the assets name for when an alert trigger occurs for that asset. There are a total of 40 assets that can be used in each copy of the script. You don't want labels from different assets printing on top of each other because you will not be able to read the asset name that the label is for. Ex. If you put your _firstLocation in the input settings as 1 and have 40 assets on this copy of the scanner then the first asset in the list is assigned to the location value 1 on the scale, and the 2nd in the list is assigned to location value 2...and so on. If your first location is set to 81 then the 1st asset is 81 and 2nd is 82 and so on.
Parameters:
_firstLocation (simple int)
Returns: - regardless of if you have the maximum amount of assets being screened (40 max), this export function will output 40 locations… So there needs to be 40 variables assigned to the tuple in this export function. What I mean by that is there needs to be 40 variables between the ' '. If you only have 20 assets in your scripts input settings, then only the first 20 variables within the ' ' Will be assigned to a value location and the other 20 will be assigned 'NA'.
SeparateTickerids(_string)
- You must form this single tickerID input string exactly as laid out in the water (a little gray circle at the end of the setting, that you hover your cursor over to read the details of). IF the string is formed correctly then it will break up. All of the tip rate is within the string into a total of 40 separate strings which will be all of the tickerIDs that the script is using in your MO scanner.
Parameters:
_string (simple string)
Returns: - this will output, 40 different security assets within the tuple output (ie. 40 variable within the ' ') regardless of if you were including 40 assets, to be screened in the MO Screener or not. if you have less than 40 assets, then once the variables are assigned to all of the tickerIDs, the rest of the variables will be assigned "NA".
TickeridForLabelsAndSecurity(_includeExchange, _ticker)
- this export function is used to output 2 tickerID strings. One is formulated to properly work in the request.security() function while the other is how it will appear on the asset name labels depending on how you form your assets string in the MO scanners input settings. Review the tooltip next to the setting, to learn how to form the string so that the asset name labels will appear how you want in the labels at the end of the line plots & the alert labels that would be triggered if the MO Scanner is set up to include Alert Trigger Labels.
Parameters:
_includeExchange (simple bool)
_ticker (simple string)
Returns: - this export function is used to output 2 tickerID strings. One is formulated to properly work in the request.security() function while the other is how it will appear on the asset name labels depending on how you form your assets string in the MO scanners input settings. Review the tooltip next to the setting, to learn how to form the string so that the asset name labels will appear how you want in the labels at the end of the line plots & the alert labels that would be triggered if the MO Scanner is set up to include Alert Trigger Labels.
PercentChange(_startingValue, _endingValue)
- this is a quick export function to calculate how much % change has occurred between the _startingValue and the _endingValue that you input into the export function.
Parameters:
_startingValue (float)
_endingValue (float)
Returns: - it will output a single percentage value between 0-100 with trailing numbers behind a decimal. If you want, only a certain amount of numbers behind the decimal, this export function needs to be put within a formatting function to do so. Explained in the MO Scanner INTRO VIDEO.
PrintedBarCount(_time, _barCntLength, _bcPmin)
- This export function will outfit the percentage of printed bars (that occurred within _barCntLength amount of time) out of the MAX amount of bars that potentially COULD HAVE been printed. Iexplanation in the MO Scanner INTRO VIDEO.
Parameters:
_time (int)
_barCntLength (int)
_bcPmin (int)
Returns: - Gives 2 outputs. The first is the total % of Printed Bars within the user set time period and second is true/false according to if the Printed BarCount % is above the _bcPmin threshold that you input into this export function.
CandlestickPatternsLibrary "CandlestickPatterns"
This library provides a wide range of candlestick patterns, and available for user to call each pattern individually. It's a comprehensive and common tool designed for traders seeking to raise their technical analysis, and it may help users identify key turning of price action in financial instruments. Credit to public technical “*All Candlestick Patterns*” indicator.
abandonedBaby(order, d1)
The "Abandoned Baby" candlestick pattern is a bullish/bearish pattern consists of three candles.
Parameters:
order (simple string) : (simple string) Pattern order type "bull" or "bear".
d1 (simple float) : (simple float) Previous candle's body percentage out of candle range. Optional argument, default is 5.
darkCloudCover(c1, n)
The "Dark Cloud Cover" is a bearish pattern consists of two candles.
Parameters:
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
doji(d0)
The "Doji" is neither bullish or bearish consists of one candles.
Parameters:
d0 (simple float) : (simple float) Current candle's body percentage out of candle range. Optional argument, default is 5.
dojiStar(order, c1, n, d0)
The "Doji Star" is a bullish/bearish pattern consists of two candles.
Parameters:
order (simple string) : (simple string) Pattern order type "bull" or "bear" .
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
d0 (simple float) : (simple float) Current candle's body percentage out of candle range. Optional argument, default is 5.
downsideTasukiGap(c2, c1, n)
The "Downside Tasuki Gap" is a bearish pattern consists of three candles.
Parameters:
c2 (simple bool) : (simple bool) Before previous candle's body must be higher than average. Optional argument, default is true.
c1 (simple bool) : (simple bool) Previous candle's body must be lower than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
dragonflyDoji(d0)
The "Dragon Fly Doji" is a bullish pattern consists of one candle.
Parameters:
d0 (simple float) : (simple float) Current candle's body percentage out of candle range. Optional argument, default is 5.
engulfing(order, c1, c0, n)
The "Engulfing" is a bullish/bearish pattern consists of two candles.
Parameters:
order (simple string) : (simple string) Pattern order type "bull" or "bear".
c1 (simple bool) : (simple bool) Previous candle's body must be lower than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
eveningDojiStar(c2, c0, d1, n)
The "Evening Doji Star" is a bearish pattern consists of three candles.
Parameters:
c2 (simple bool) : (simple bool) Before previous candle's body must be higher than average, default is true.
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
d1 (simple float) : (simple float) Previous candle's body percentage out of candle range. Optional argument, default is 5.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
eveningStar(c2, c1, c0, n)
The "Evening Star" is a bearish pattern consists of three candles.
Parameters:
c2 (simple bool) : (simple bool) Before previous candle's body must be higher than average. Optional argument, default is true.
c1 (simple bool) : (simple bool) Previous candle's body must be lower than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
fallingThreeMethods(c4, c3, c2, c1, c0, n)
The "Falling Three Methods" is a bearish pattern consists of five candles.
Parameters:
c4 (simple bool) : (simple bool) 5th candle ago body must be higher than average. Optional argument, default is true.
c3 (simple bool) : (simple bool) 4th candle ago body must be lower than average. Optional argument, default is true.
c2 (simple bool) : (simple bool) 3rd candle ago body must be lower than average. Optional argument, default is true.
c1 (simple bool) : (simple bool) 2nd candle ago body must be lower than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
Returns: (bool)
fallingWindow()
The "Falling Window" is a bearish pattern consists of two candles.
gravestoneDoji(d0)
The "Gravestone Doji" is a bearish pattern consists of one candle.
Parameters:
d0 (simple float) : (simple float) Current candle's body percentage out of candle range. Optional argument, default is 5.
hammer(c0, n)
The "Hammer" is a bullish pattern consists of one candle.
Parameters:
c0 (simple bool) : (simple bool) Current candle's body must be lower than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
hangingMan(c0, n)
The "Hanging Man" is a bearish pattern consists of one candle.
Parameters:
c0 (simple bool) : (simple bool) Current candle's body must be lower than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
haramiCross(order, c1, n)
The "Harami Cross" candlestick pattern is a bullish/bearish pattern consists of two candles.
Parameters:
order (string) : (simple string) Pattern order type "bull" or "bear".
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
harami(order, c1, c0, n)
The "Harami" candlestick pattern is a bullish/bearish pattern consists of two candles.
Parameters:
order (string) : (simple string) Pattern order type "bull" or "bear"
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Current candle's body must be lower than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
invertedHammer(c0, n)
The "Inverted Hammer" is a bullish pattern consists of one candle.
Parameters:
c0 (simple bool) : (simple bool) Current candle's body must be lower than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
kicking(order, c1, c0, n)
The "Kicking" candlestick pattern is a bullish/bearish pattern consists of two candles.
Parameters:
order (string) : (simple string) Pattern order type "bull" or "bear"
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
longLowerShadow(l0)
The "Long Lower Shadow" candlestick pattern is a bullish pattern consists of one candles.
Parameters:
l0 (simple float) : (simple float) Current candle's lower wick min percentage out of candle range. Optional argument, default is 75.
longUpperShadow(u0)
The "Long Upper Shadow" candlestick pattern is a bearish pattern consists of one candles.
Parameters:
u0 (simple float) : (simple float) Current candle's upper wick min percentage out of candle range. Optional argument, default is 75.
marubozuBlack(c0, n)
The "Marubozu Black" candlestick pattern is a bearish pattern consists of one candles.
Parameters:
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
marubozuWhite(c0, n)
The "Marubozu White" candlestick pattern is a bullish pattern consists of one candles.
Parameters:
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
morningDojiStar(c2, d1, c0, n)
The "Morning Doji Star" candlestick pattern is a bullish pattern consists of three candles.
Parameters:
c2 (simple bool) : (simple bool) Before previous candle's body must be higher than average. Optional argument, default is true.
d1 (simple float) : (simple float) Previous candle's body percentage out of candle range. Optional argument, default is 5.
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
morningStar(c2, c1, c0, n)
The "Morning Star" candlestick pattern is a bullish pattern consists of three candles.
Parameters:
c2 (simple bool) : (simple bool) Before previous candle's body must be higher than average. Optional argument, default is true.
c1 (simple bool) : (simple bool) Previous candle's body must be lower than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Cuurent candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
onNeck(c1, c0, n)
The "On Neck" candlestick pattern is a bearish pattern consists of two candles.
Parameters:
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Cuurent candle's body must be lower than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
piercing(c1, n)
The "Piercing" candlestick pattern is a bullish pattern consists of two candles.
Parameters:
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
risingThreeMethods(c4, c3, c2, c1, c0, n)
The "Rising Three Methods" candlestick pattern is a bullish pattern consists of five candles.
Parameters:
c4 (simple bool) : (simple bool) 5th candle ago body must be higher than average. Optional argument, default is true.
c3 (simple bool) : (simple bool) 4th candle ago body must be Lower than average. Optional argument, default is true.
c2 (simple bool) : (simple bool) 3rd candle ago body must be Lower than average. Optional argument, default is true.
c1 (simple bool) : (simple bool) 2nd candle ago body must be Lower than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
risingWindow()
The "Rising Window" candlestick pattern is a bullish pattern consists of two candle.
shootingStar(c0, n)
The "Shooting Star" candlestick pattern is a bearish pattern consists of one candle.
Parameters:
c0 (simple bool) : (simple bool) Current candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
spinningTopBlack(l0, u0)
The "Spinning Top Black" is neither bullish or bearish.
Parameters:
l0 (simple float) : (simple float) Current candle's lower wick min percentage out of candle range. Optional argument, default is 34.
u0 (simple float) : (simple float) Current candle's upper wick min percentage out of candle range. Optional argument, default is 34.
spinningTopWhite(l0, u0)
The "Spinning Top White" is neither bullish or bearish.
Parameters:
l0 (simple float) : (simple float) Current candle's lower wick min percentage out of candle range. Optional argument, default is 34.
u0 (simple float) : (simple float) Current candle's upper wick min percentage out of candle range. Optional argument, default is 34.
threeBlackCrows(c2, c1, c0, n)
The "Three Black Crows" candlestick pattern is a bearish pattern consists of three candles.
Parameters:
c2 (simple bool) : (simple bool) Before previous candle's body must be higher than average. Optional argument, default is true.
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Cuurent candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
threeWhiteSoldiers(c2, c1, c0, n)
The "Three White Soldiers" candlestick pattern is a bullish pattern consists of three candles.
Parameters:
c2 (simple bool) : (simple bool) Before previous candle's body must be higher than average. Optional argument, default is true.
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
c0 (simple bool) : (simple bool) Cuurent candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
triStar(order, d2, d1, d0)
The "Tri Star" candlestick pattern is a bullish/bearish pattern consists of three candles.
Parameters:
order (simple string) : (simple string) Pattern order type "bull" or "bear".
d2 (simple float) : (simple float) Before previous candle's body percentage out of candle range. Optional argument, default is 5.
d1 (simple float) : (simple float) Previous candle's body percentage out of candle range. Optional argument, default is 5.
d0 (simple float) : (simple float) Current candle's body percentage out of candle range. Optional argument, default is 5.
tweezerBottom(c1, n)
The "Tweezer Bottom" candlestick pattern is a bullish pattern consists of two candles.
Parameters:
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
tweezerTop(c1, n)
The "Tweezer Top" candlestick pattern is a bearish pattern consists of two candles.
Parameters:
c1 (simple bool) : (simple bool) Previous candle's body must be higher than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
upsideTasukiGap(c2, c1, n)
The "Tri Star" candlestick pattern is a bullish pattern consists of three candles.
Parameters:
c2 (simple bool) : (simple bool) Before Previous candle's body must be higher than average. Optional argument, default is true.
c1 (simple bool) : (simple bool) Previous candle's body must be lower than average. Optional argument, default is true.
n (simple int) : (simple int) Length of average candle's body. Optional argument, default is 14.
JapaneseCandlestickPatternsLibrary "JapaneseCandlestickPatterns"
Japanese Candlestick Patterns is a library of functions that enables the detection of popular Japanese candlestick patterns such as Doji, Hammer, and Engulfing, among others. The library provides a simple yet powerful way to analyze financial markets and make informed trading decisions. Japanese Candlestick Patterns library can help you identify potential trading opportunities.
isDojiCandle()
isGravestoneDojiCandle()
isDragonflyDojiCandle()
isEveningDojiStarCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isLongLeggedDojiCandle()
isMorningDojiStarCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isBullishCounterattackLinesCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isBearishCounterattackLinesCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isDarkCloudCoverCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isBullishEngulfingCandle()
isBearishEngulfingCandle()
isHammerCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isHangingManCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isHaramiBearishCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isHaramiBullishCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isInNeckCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isOnNeckCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isPiercingCandle(isDownTrend)
Parameters:
isDownTrend (bool)
threeBlackCrowsCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isThrustingNeckCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isUpsideGapTwoCrowsCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isAbandonedBabyTopCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isAbandonedBabyBottomCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isEveningStarCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isInvertedHammerCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isMorningStarCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isShootingStarCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isRisingThreeMethodsCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isFallingThreeMethodsCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isUpsideTasukiGapCandle(isUpTrend)
Parameters:
isUpTrend (bool)
isDownsideGapTasukiCandle(isDownTrend)
Parameters:
isDownTrend (bool)
isLongLowerShadowCandle()
isLongUpperShadowCandle()
gFancyMALibrary "gFancyMA"
printLbl(y, x, c, m, b, s)
Parameters:
y (float)
x (int)
c (color)
m (string)
b (bool)
s (string)
ATR_InfoWhat Is the Average True Range (ATR)?
The average true range (ATR) is a technical analysis indicator, introduced by market technician J. Welles Wilder Jr. in his book New Concepts in Technical Trading Systems, that measures market volatility by decomposing the entire range of an asset price for that period.
Each instrument per unit of time passes its average value of the true range, but there are moments when the volatility explodes or abruptly decays, these phenomena introduce large distortions into the average value of the true range.
The ATR_WPB function calculates the average value of the true range for the specified number of bars, while excluding paranormally large and paranormally small bars from the calculation of the average.
For example, if the instrument has passed a small ATR value, then it has many chances to continue moving, but if the instrument has passed its ATR value, then the chances of continuing to move are extremely low.
Library "ATR_Info"
ATR_Info: Calculates ATR without paranormal bars
ATR_WPB(source, period, psmall, pbig)
ATR_WPB: Calculates ATR without paranormal bars
Parameters:
source (float) : ATR_WPB: (series float) The sequence of data on the basis of which the ATP calculation will be made
period (int) : ATR_WPB: (int) Sequence size for ATR calculation
psmall (float) : ATR_WPB: (float) Coefficient for paranormally small bar
pbig (float) : ATR_WPB: (float) Coefficient for paranormally big bar
Returns: ATR_WPB: (float) ATR without paranormal bars
gFancyMALibrary "GalacticS2021"
printLbl(y, x, c, m, b)
Parameters:
y (float)
x (int)
c (color)
m (string)
b (bool)
lib_zigLibrary "lib_zig"
Object oriented implementation of ZigZag
method tostring(this, date_format)
Namespace types: Zigzag
Parameters:
this (Zigzag)
date_format (simple string)
method update(this)
Namespace types: Zigzag
Parameters:
this (Zigzag)
method draw(this, colors)
Namespace types: Zigzag
Parameters:
this (Zigzag)
colors (PivotColors type from robbatt/lib_pivot/19)
Zigzag
Fields:
max_pivots (series__integer)
hldata (|robbatt/lib_pivot/19;HLData|#OBJ)
pivots (array__|robbatt/lib_pivot/19;Pivot|#OBJ)
lib_pivotLibrary "lib_pivot"
Object oriented implementation of Pivot methods.
method tostring(this)
Converts HLData to a json string representation
Namespace types: HLData
Parameters:
this (HLData) : HLData
Returns: string representation of Pivot
method tostring(this, date_format)
Namespace types: Pivot
Parameters:
this (Pivot)
date_format (simple string)
method tostring(this, date_format)
Namespace types: Pivot
Parameters:
this (Pivot )
date_format (simple string)
method get_color(this, mode)
Namespace types: PivotColors
Parameters:
this (PivotColors)
mode (int)
method get_label_text(this)
Namespace types: Pivot
Parameters:
this (Pivot)
method direction(this)
Namespace types: Pivot
Parameters:
this (Pivot)
method same_direction_as(this, other)
Namespace types: Pivot
Parameters:
this (Pivot)
other (Pivot)
method exceeds(this, price)
Namespace types: Pivot
Parameters:
this (Pivot)
price (float)
method exceeds(this, other)
Namespace types: Pivot
Parameters:
this (Pivot)
other (Pivot)
method exceeded_by(this, price)
Namespace types: Pivot
Parameters:
this (Pivot)
price (float)
method exceeded_by(this, other)
Namespace types: Pivot
Parameters:
this (Pivot)
other (Pivot)
method retracement_ratio(this, lastPivot, sec_lastPivot)
Namespace types: Pivot
Parameters:
this (Pivot)
lastPivot (Pivot)
sec_lastPivot (Pivot)
ratio_target(sec_lastPivot, lastPivot, target_ratio)
Parameters:
sec_lastPivot (Pivot)
lastPivot (Pivot)
target_ratio (float)
method update(this, ref_highest, ref_lowest)
Namespace types: HLData
Parameters:
this (HLData)
ref_highest (float)
ref_lowest (float)
method update(this, bar_time, bar_idx, price, prev)
Namespace types: Pivot
Parameters:
this (Pivot)
bar_time (int)
bar_idx (int)
price (float)
prev (Pivot)
method create_next(this, bar_time, bar_idx, price)
Namespace types: Pivot
Parameters:
this (Pivot)
bar_time (int)
bar_idx (int)
price (float)
HLData
HLData wraps the data received from ta.highest, ta.highestbars, ta.lowest, ta.lowestbars, as well as the reference sources
Fields:
length (series int) : lookback length for pivot points
highest_offset (series int) : offset to highest value bar
lowest_offset (series int) : offset to lowest value bar
highest (series float) : highest value within lookback bars
lowest (series float) : lowest value within lookback bars
new_highest (series bool) : update() will set this true if the current candle forms a new highest high at the last (current) bar of set period (length)
new_lowest (series bool) : update() will set this true if the current candle forms a new lowest low at the last (current) bar of set period (length)
new_highest_fractal (series bool) : update() will set this true if the current candle forms a new fractal high at the center of set period (length)
new_lowest_fractal (series bool) : update() will set this true if the current candle forms a new fractal low at the center of set period (length)
PivotColors
Pivot colors for different modes
Fields:
hh (series color) : Color for Pivot mode 2 (HH)
lh (series color) : Color for Pivot mode 1 (LH)
hl (series color) : Color for Pivot mode -1 (HL)
ll (series color) : Color for Pivot mode -2 (LL)
Pivot
Pivot additional pivot data around basic Point
Fields:
point (Point type from robbatt/lib_plot_objects/5)
mode (series int) : can be -2/-1/1/2 for LL/HL/LH/HH
price_movement (series float) : The price difference between this and the previous pivot point in the opposite direction
retracement_ratio (series float) : The ratio between this price_movement and the previous
prev (Pivot)
lib_priceactionLibrary "lib_priceaction"
a library for everything related to price action, starting off with displacements
displacement(len, min_strength, o, c)
calculate if there is a displacement and how strong it is
Parameters:
len (int) : The amount of candles to consider for the deviation
min_strength (float) : The minimum displacement strength to trigger a signal
o (float) : The source series on which calculations are based
c (float) : The source series on which calculations are based
Returns: a tuple of (bool signal, float displacement_strength)
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:
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)
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)