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.
Techindicator
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)
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)
HelperTALibrary "HelperTA"
This library contains useful technical indicators that I use regularly in my charts.
`stockRSI` is not mine, but included because used often and referenced by internal functions.
`DCO` is a normalisation of the donchian channels; the price relative to the donchian channels, on a range.
`MarketCycle` is a weighted aggregate of RSI, Stochastic RSI & DCO (demo on the chart)
stockRSI(src, K, D, rsiPeriod, stochPeriod)
stockRSI
Parameters:
src (float)
K (int)
D (int)
rsiPeriod (simple int)
stochPeriod (int)
Returns:
DCO(price, donchianPeriod, smaPeriod)
DCO
Parameters:
price (float)
donchianPeriod (int)
smaPeriod (int)
Returns:
MarketCycle(donchianPrice, rsiPrice, srsiPrice, donchianPeriod, donchianSmoothing, rsiPeriod, rsiSmoothing, srsiPeriod, srsiSmoothing, srsiK, srsiD, rsiWeight, srsiWeight, dcoWeight)
MarketCycle
Parameters:
donchianPrice (float)
rsiPrice (float)
srsiPrice (float)
donchianPeriod (simple int)
donchianSmoothing (simple int)
rsiPeriod (simple int)
rsiSmoothing (int)
srsiPeriod (simple int)
srsiSmoothing (simple int)
srsiK (simple int)
srsiD (simple int)
rsiWeight (simple float)
srsiWeight (simple float)
dcoWeight (simple float)
Returns:
CurrentlyPositionIndicatorLibrary "CurrentlyPositionIndicator"
Currently position indicator
run(_index, _price, _stoploss, _high, _low, _side, _is_entered, _colors, _position_left, _box_width)
Currently positions indicator
Parameters:
_index (int) : entry index
_price (float) : entry price
_stoploss (float) : stoploss price
_high (float) : range high
_low (float) : range low
_side (int)
_is_entered (bool) : is entered
_colors (color ) : color array
_position_left (int) : Left position
_box_width (int) : box's width
Returns: TODO: add what function returns
BankNifty_CSMLibrary "BankNifty_CSM"
TODO: add library description here
getLtp_N_Chang(openPrice, closePrice, highPrice, hl2Price, lowPrice, hlc3Price, bankNiftyClose)
Parameters:
openPrice (float)
closePrice (float)
highPrice (float)
hl2Price (float)
lowPrice (float)
hlc3Price (float)
bankNiftyClose (float)
ka66: lib/MovingAveragesLibrary "MovingAverages"
Exotic or Interesting Moving Averages Collection. Just the one right now!
alphaConfigurableEma(src, alpha, nSmooth)
Calculates a variation of the EMA by specifying a custom alpha value.
Parameters:
src (float) : a float series to get the EMA for, e.g. close, hlc3, etc.
alpha (float) : a value between 0 (ideally greater, to get any MA!) and 1. Closer
to one makes it more responsive, and choppier.
nSmooth (int) : Just applies the same alpha and EMA to the last Alpha-EMA output.
A value between 0 and 10 (just keeping a a reasonable bound). The idea is
you can first use a reasonably high alpha, then smooth it out. Default 0,
no further smoothing.
Returns: MA series.
bands(src, multiplier)
Calculates fixed bands around a series, can be any series, though the intent
here is for MA series.
Parameters:
src (float) : a float series.
multiplier (float) : a value greater than or equal to 0 (ideally greater, to get any MA!),
determines the width of the bands. Start with small float values, or it may go
beyond the scale, e.g. 0.005.
Returns: a 2-tuple of (upBand, downBand)
Spider_PlotIntroduction:
Spider charts, also known as radar charts or web charts, are a powerful data visualization tool that can display multiple variables in a circular format. They are particularly useful when you want to compare different data sets or evaluate the performance of a single data set across multiple dimensions. In this blog post, we will dive into the world of spider charts, explore their benefits, and demonstrate how you can create your own spider chart using the Spider_Plot library.
Why Spider Charts are Cool:
Spider charts have a unique visual appeal that sets them apart from other chart types. They allow you to display complex data in a compact, easy-to-understand format, making them perfect for situations where you need to convey a lot of information in a limited space. Some of the key benefits of spider charts include:
Multi-dimensional analysis: Spider charts can display multiple variables at once, making them ideal for analyzing relationships between different data sets or examining a single data set across multiple dimensions.
Easy comparison: By displaying data in a circular format, spider charts make it simple to compare different data points, identify trends, and spot potential issues.
Versatility: Spider charts can be used for a wide range of applications, from business and finance to sports and health. They are particularly useful for situations where you need to analyze performance or make comparisons between different entities.
Creating Your Own Spider Chart with the Spider_Plot Library:
The Spider_Plot library is a user-friendly, easy-to-use tool that allows you to create stunning spider charts with minimal effort. To get started, you'll need to import the Spider_Plot library:
import peacefulLizard50262/Spider_Plot/1
With the library imported, you can now create your own spider chart. The first step is to normalize your data. Normalizing ensures that all data points fall within the 0 to 1 range, which is important for creating a visually balanced spider chart.
The Spider_Plot library provides the data_normalize function to help you normalize your data. This function accepts several parameters, including the normalization style ("All Time", "Range", or "Custom"), length of the range, outlier level, lookback period for standard deviation, and minimum and maximum values for the "Custom" normalization style.
Once you have normalized your data, you can create an array of your data points using the array.from function. This array will be used as input for the draw_spider_plot function, which is responsible for drawing the spider plot on your chart.
The draw_spider_plot function accepts an array of float values (the normalized data points), an array of background colors for each sector, a color for the axes, and a scaling factor.
Example Usage:
Here's an example script that demonstrates how to create a spider chart using the Spider_Plot library:
oc = data_normalize(ta.ema(math.abs(open - close), 20), "Range", 20)
// Create an array of your data points
data = array.from(tr, rsi, stoch, dev, tr, oc, tr)
// Define colors for each sector
colors = array.from(color.new(color.red, 90), color.new(color.blue, 90), color.new(color.green, 90), color.new(color.orange, 90), color.new(color.purple, 90), color.new(color.purple, 90), color.new(color.purple, 90))
// Draw the spider plot on your chart
draw_spider_plot(data, colors, color.gray, 100)
In this example, we have first normalized six different data points (rsi, source, stoch, dev, tr, and oc) using the data_normalize function. Next, we create an array of these normalized data points and define an array of colors for each sector of the spider chart. Finally, we call the draw_spider_plot function to draw the spider chart on our chart.
Conclusion:
Spider charts are a versatile and visually appealing tool for analyzing and comparing multi-dimensional data. With the Spider_Plot library, you can easily create your own spider charts and unlock valuable insights from your data. Just remember to normalize your data and create an array of data points before calling the draw_spider_plot function. Happy charting!
Library "Spider_Plot"
data_normalize(data, style, length, outlier_level, dev_lookback, min, max)
data_normalize(data, string style, int length, float outlier_level, simple int dev_lookback, float min, float max)
Parameters:
data (float) : float , A float value to normalize.
style (string) : string , The normalization style: "All Time", "Range", or "Custom".
length (int) : int , The length of the range for "Range" normalization style.
outlier_level (float) : float , The outlier level to exclude from calculations.
dev_lookback (simple int) : int , The lookback period for calculating the standard deviation.
min (float) : float , The minimum value for the "Custom" normalization style.
max (float) : float , The maximum value for the "Custom" normalization style.
Returns: array , The normalized float value.
draw_spider_plot(values, bg_colors, axes_color, scale)
draw_spider_plot(array values, array bg_colors, color axes_color, float scale)
Parameters:
values (float ) : array , An array of float values to plot in the spider plot.
bg_colors (color ) : array , An array of background colors for each sector in the spider plot.
axes_color (color) : color , The color of the axes in the spider plot. Default: color.gray
scale (float) : float , A scaling factor for the spider plot. Default: 10
Returns: void , Draws the spider plot on the chart.