The Divergent LibraryLibrary "TheDivergentLibrary"
The Divergent Library is only useful when combined with the Pro version of The Divergent - Advanced divergence indicator . This is because the Basic (free) version of The Divergent does not expose the "Divergence Signal" value.
Usage instructions:
1. Create a new chart
2. Add The Divergent (Pro) indicator to your chart
3. Create a new strategy, import this library, add a "source" input, link it to "The Divergent: Divergence Signal", and use the library to decode the divergence signals from The Divergent (You can find example strategy code published in our profile)
4. Act on the divergences signalled by The Divergent
---
isRegularBullishEnabled(context) Returns a boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
isHiddenBullishEnabled(context) Returns a boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
isRegularBearishEnabled(context) Returns a boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
isHiddenBearishEnabled(context) Returns a boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
getPivotDetectionSource(context) Returns the 'Pivot Detection Source' setting of The Divergent. The returned value can be either "Oscillator" or "Price".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Oscillator" or "Price".
getPivotDetectionMode(context) Returns the 'Pivot Detection Mode' setting of The Divergent. The returned value can be either "Bodies" or "Wicks".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Bodies" or "Wicks".
isLinked(context) Returns a boolean value indicating the link status to The Divergent indicator.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating the link status to The Divergent indicator.
init(firstBarSignal, displayLinkStatus, debug) Initialises The Divergent Library's context with the signal produced by The Divergent on the first bar. The value returned from this function is called the "context of The Divergent Library". Some of the other functions of this library requires you to pass in this context.
Parameters:
firstBarSignal : The signal from The Divergent indicator on the first bar.
displayLinkStatus : A boolean value indicating whether the Link Status window should be displayed in the bottom left corner of the chart. Defaults to true.
debug : A boolean value indicating whether the Link Status window should display debug information. Defaults to false.
Returns: A bool array containing the context of The Divergent Library.
processSignal(signal) Processes a signal from The Divergent and returns a 5-tuple with the decoded signal: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd]. `divergenceType` can be one of the following values: na → No divergence was detected, 1 → Regular Bullish, 2 → Regular Bullish early, 3 → Hidden Bullish, 4 → Hidden Bullish early, 5 → Regular Bearish, 6 → Regular Bearish early, 7 → Hidden Bearish, 8 → Hidden Bearish early.
Parameters:
signal : The signal from The Divergent indicator.
Returns: A 5-tuple with the following values: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd].
Techindicator
Library_RICHLibrary "Library_RICH"
TODO: add library description here
sum(x) TODO: add function description here
Parameters:
x : TODO: add parameter x description here
Returns: TODO: add what function returns
checkBuyReversal() : ckeck if there are buy reversal conditions (divergences) in rsi
insure that the bar count since the last pivot low is within the specified range (min- and max range)
ckeck if there is a higher-low in rsi and lower-low in the price
(doubel) ckeck if buy reversal condition is true
Parameters:
: : rsi value, pivot left lenght, pivot right lenght, min. and max. range
Returns: : two values: bar-reversal-condition (true) and pivot low if is true
checkBuyContinuation() : ckeck if there are buy cintinuation conditions (hidden divergences) in rsi
insure that the bar count since the last pivot low is within the specified range (min- and max range)
ckeck if there is a lower-low in rsi and higher-low in the price
(doubel) ckeck if buy continuation condition is true
Parameters:
: : rsi value, pivot left lenght, pivot right lenght, min. and max. range
Returns: : two results: bar-reversal-condition (true) and pivot low, if is true
checkSellReversal() : ckeck if there are sell reversal conditions (divergences) in rsi
insure that the bar count since the last pivot high is within the specified range (min- and max range)
ckeck if there is a lower-high in rsi and higher-high in the price
(doubel) ckeck if sell reversal condition is true
Parameters:
: : rsi value, pivot left lenght, pivot right lenght, min. and max. range
Returns: : two results: sell-reversal-condition (true) and pivot high, if is true
checkSellContinuation() : ckeck if there are sell cointunuation conditions (divergences) in rsi
insure that the bar count since the last pivot high is within the specified range (min- and max range)
ckeck if there is a higher-high in rsi and lower-high in the price
(doubel) ckeck if sell continuation condition is true
Parameters:
: : rsi value, pivot left lenght, pivot right lenght, min. and max. range
Returns: : two results: sell-continuation-condition (true) and pivot high, if is true
ConverterTFLibrary "ConverterTF"
I have found a bug Regarding the timeframe display, on the chart I have found that the display is numeric, for example 4Hr timeframe instead of '4H', but it turns out to be '240', which I want it to be displayed in abbreviated form. And in all other timeframes it's the same. So this library was created to solve those problems. It converts a timeframe from a numeric string type to an integer type by selecting a timeframe manually and displaying it on the chart.
CTF()
str = "240"
X.GetTF( str )
Example
str = input.timeframe(title='Time frame', defval='240')
TimeF = CTF(str)
L=label.new(bar_index, high, 'Before>> Timeframe '+str+' After>> Timeframe '+TimeF,style=label.style_label_down,size=size.large)
label.delete(L )
Custom timeframes can handle this issue as well.
An example from the use. You will find it on the bottom right hand side.
Hopefully it will be helpful to the Tradingview community. :)
lib_Indicators_v2_DTULibrary "lib_Indicators_v2_DTU"
This library functions returns included Moving averages, indicators with factorization, functions candles, function heikinashi and more.
Created it to feed as backend of my indicator/strategy "Indicators & Combinations Framework Advanced v2 " that will be released ASAP.
This is replacement of my previous indicator (lib_indicators_DT)
I will add an indicator example which will use this indicator named as "lib_indicators_v2_DTU example" to help the usage of this library
Additionally library will be updated with more indicators in the future
NOTES:
Indicator functions returns only one series :-(
plotcandle function returns candle series
INDICATOR LIST:
hide = 'DONT DISPLAY', //Dont display & calculate the indicator. (For my framework usage)
alma = 'alma(src,len,offset=0.85,sigma=6)', //Arnaud Legoux Moving Average
ama = 'ama(src,len,fast=14,slow=100)', //Adjusted Moving Average
acdst = 'accdist()', //Accumulation/distribution index.
cma = 'cma(src,len)', //Corrective Moving average
dema = 'dema(src,len)', //Double EMA (Same as EMA with 2 factor)
ema = 'ema(src,len)', //Exponential Moving Average
gmma = 'gmma(src,len)', //Geometric Mean Moving Average
hghst = 'highest(src,len)', //Highest value for a given number of bars back.
hl2ma = 'hl2ma(src,len)', //higest lowest moving average
hma = 'hma(src,len)', //Hull Moving Average.
lgAdt = 'lagAdapt(src,len,perclen=5,fperc=50)', //Ehler's Adaptive Laguerre filter
lgAdV = 'lagAdaptV(src,len,perclen=5,fperc=50)', //Ehler's Adaptive Laguerre filter variation
lguer = 'laguerre(src,len)', //Ehler's Laguerre filter
lsrcp = 'lesrcp(src,len)', //lowest exponential esrcpanding moving line
lexp = 'lexp(src,len)', //lowest exponential expanding moving line
linrg = 'linreg(src,len,loffset=1)', //Linear regression
lowst = 'lowest(src,len)', //Lovest value for a given number of bars back.
pcnl = 'percntl(src,len)', //percentile nearest rank. Calculates percentile using method of Nearest Rank.
pcnli = 'percntli(src,len)', //percentile linear interpolation. Calculates percentile using method of linear interpolation between the two nearest ranks.
rema = 'rema(src,len)', //Range EMA (REMA)
rma = 'rma(src,len)', //Moving average used in RSI. It is the exponentially weighted moving average with alpha = 1 / length.
sma = 'sma(src,len)', //Smoothed Moving Average
smma = 'smma(src,len)', //Smoothed Moving Average
supr2 = 'super2(src,len)', //Ehler's super smoother, 2 pole
supr3 = 'super3(src,len)', //Ehler's super smoother, 3 pole
strnd = 'supertrend(src,len,period=3)', //Supertrend indicator
swma = 'swma(src,len)', //Sine-Weighted Moving Average
tema = 'tema(src,len)', //Triple EMA (Same as EMA with 3 factor)
tma = 'tma(src,len)', //Triangular Moving Average
vida = 'vida(src,len)', //Variable Index Dynamic Average
vwma = 'vwma(src,len)', //Volume Weigted Moving Average
wma = 'wma(src,len)', //Weigted Moving Average
angle = 'angle(src,len)', //angle of the series (Use its Input as another indicator output)
atr = 'atr(src,len)', //average true range. RMA of true range.
bbr = 'bbr(src,len,mult=1)', //bollinger %%
bbw = 'bbw(src,len,mult=2)', //Bollinger Bands Width. The Bollinger Band Width is the difference between the upper and the lower Bollinger Bands divided by the middle band.
cci = 'cci(src,len)', //commodity channel index
cctbb = 'cctbbo(src,len)', //CCT Bollinger Band Oscilator
chng = 'change(src,len)', //Difference between current value and previous, source - source .
cmo = 'cmo(src,len)', //Chande Momentum Oscillator. Calculates the difference between the sum of recent gains and the sum of recent losses and then divides the result by the sum of all price movement over the same period.
cog = 'cog(src,len)', //The cog (center of gravity) is an indicator based on statistics and the Fibonacci golden ratio.
cpcrv = 'copcurve(src,len)', //Coppock Curve. was originally developed by Edwin "Sedge" Coppock (Barron's Magazine, October 1962).
corrl = 'correl(src,len)', //Correlation coefficient. Describes the degree to which two series tend to deviate from their ta.sma values.
count = 'count(src,len)', //green avg - red avg
dev = 'dev(src,len)', //ta.dev() Measure of difference between the series and it's ta.sma
fall = 'falling(src,len)', //ta.falling() Test if the `source` series is now falling for `length` bars long. (Use its Input as another indicator output)
kcr = 'kcr(src,len,mult=2)', //Keltner Channels Range
kcw = 'kcw(src,len,mult=2)', //ta.kcw(). Keltner Channels Width. The Keltner Channels Width is the difference between the upper and the lower Keltner Channels divided by the middle channel.
macd = 'macd(src,len)', //macd
mfi = 'mfi(src,len)', //Money Flow Index
nvi = 'nvi()', //Negative Volume Index
obv = 'obv()', //On Balance Volume
pvi = 'pvi()', //Positive Volume Index
pvt = 'pvt()', //Price Volume Trend
rise = 'rising(src,len)', //ta.rising() Test if the `source` series is now rising for `length` bars long. (Use its Input as another indicator output)
roc = 'roc(src,len)', //Rate of Change
rsi = 'rsi(src,len)', //Relative strength Index
smosc = 'smi_osc(src,len,fast=5, slow=34)', //smi Oscillator
smsig = 'smi_sig(src,len,fast=5, slow=34)', //smi Signal
stdev = 'stdev(src,len)', //Standart deviation
trix = 'trix(src,len)' , //the rate of change of a triple exponentially smoothed moving average.
tsi = 'tsi(src,len)', //True Strength Index
vari = 'variance(src,len)', //ta.variance(). Variance is the expectation of the squared deviation of a series from its mean (ta.sma), and it informally measures how far a set of numbers are spread out from their mean.
wilpc = 'willprc(src,len)', //Williams %R
wad = 'wad()', //Williams Accumulation/Distribution.
wvad = 'wvad()' //Williams Variable Accumulation/Distribution.
}
f_func(string, float, simple, float, float, float, simple) f_func Return selected indicator value with different parameters. New version. Use extra parameters for available indicators
Parameters:
string : FuncType_ indicator from the indicator list
float : src_ close, open, high, low,hl2, hlc3, ohlc4 or any
simple : int length_ indicator length
float : p1 extra parameter-1. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
float : p2 extra parameter-2. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
float : p3 extra parameter-3. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
simple : int version_ indicator version for backward compatibility. V1:dont use extra parameters p1,p2,p3 and use default values. V2: use extra parameters for available indicators
Returns: float Return calculated indicator value
fn_heikin(float, float, float, float) fn_heikin Return given src data (open, high,low,close) as heikin ashi candle values
Parameters:
float : o_ open value
float : h_ high value
float : l_ low value
float : c_ close value
Returns: float heikin ashi open, high,low,close vlues that will be used with plotcandle
fn_plotFunction(float, string, simple, bool) fn_plotFunction Return input src data with different plotting options
Parameters:
float : src_ indicator src_data or any other series.....
string : plotingType Ploting type of the function on the screen
simple : int stochlen_ length for plotingType for stochastic and PercentRank options
bool : plotSWMA Use SWMA for smoothing Ploting
Returns: float
fn_funcPlotV2(string, float, simple, float, float, float, simple, string, simple, bool, bool) fn_funcPlotV2 Return selected indicator value with different parameters. New version. Use extra parameters fora available indicators
Parameters:
string : FuncType_ indicator from the indicator list
float : src_data_ close, open, high, low,hl2, hlc3, ohlc4 or any
simple : int length_ indicator length
float : p1 extra parameter-1. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
float : p2 extra parameter-2. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
float : p3 extra parameter-3. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
simple : int version_ indicator version for backward compatibility. V1:dont use extra parameters p1,p2,p3 and use default values. V2: use extra parameters for available indicators
string : plotingType Ploting type of the function on the screen
simple : int stochlen_ length for plotingType for stochastic and PercentRank options
bool : plotSWMA Use SWMA for smoothing Ploting
bool : log_ Use log on function entries
Returns: float Return calculated indicator value
fn_factor(string, float, simple, float, float, float, simple, simple, string, simple, bool, bool) fn_factor Return selected indicator's factorization with given arguments
Parameters:
string : FuncType_ indicator from the indicator list
float : src_data_ close, open, high, low,hl2, hlc3, ohlc4 or any
simple : int length_ indicator length
float : p1 parameter-1. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
float : p2 parameter-2. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
float : p3 parameter-3. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
simple : int version_ indicator version for backward compatibility. V1:dont use extra parameters p1,p2,p3 and use default values. V2: use extra parameters for available indicators
simple : int fact_ Add double triple, Quatr factor to selected indicator (like converting EMA to 2-DEMA, 3-TEMA, 4-QEMA...)
string : plotingType Ploting type of the function on the screen
simple : int stochlen_ length for plotingType for stochastic and PercentRank options
bool : plotSWMA Use SWMA for smoothing Ploting
bool : log_ Use log on function entries
Returns: float Return result of the function
fn_plotCandles(string, simple, float, float, float, simple, string, simple, bool, bool, bool) fn_plotCandles Return selected indicator's candle values with different parameters also heikinashi is available
Parameters:
string : FuncType_ indicator from the indicator list
simple : int length_ indicator length
float : p1 parameter-1. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
float : p2 parameter-2. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
float : p3 parameter-3. active on Version 2 for defining multi arguments indicator input value. ex: lagAdapt(src_, length_,LAPercLen_=p1,FPerc_=p2)
simple : int version_ indicator version for backward compatibility. V1:dont use extra parameters p1,p2,p3 and use default values. V2: use extra parameters for available indicators
string : plotingType Ploting type of the function on the screen
simple : int stochlen_ length for plotingType for stochastic and PercentRank options
bool : plotSWMA Use SWMA for smoothing Ploting
bool : log_ Use log on function entries
bool : plotheikin_ Use Heikin Ashi on Plot
Returns: float
library TypeMovingAveragesLibrary "TypeMovingAverages"
This library function returns a moving average.
ma_fast
ma_slow
MA_selector()
Example
// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © hapharmonic
//@version=5
indicator("Test MATYPE", overlay=true)
import hapharmonic/TypeMovingAverages/1 as MAType
xprd1 = input(title=' 💉Fast EMA period', defval=12)
ma_select1 = 'EMA'
xprd2 = input(title=' 💉Fast EMA period', defval=26)
ma_select2 = 'EMA'
xsmooth = input.int(title='🏄♂️Smoothing period (1 = no smoothing)', minval=1, defval=1)
ma_fast = MAType.MA_selector(close, xprd1, ma_select1,xsmooth)
ma_slow = MAType.MA_selector(close, xprd2, ma_select2,xsmooth)
plot(ma_fast, "INDICATOR",color.green)
plot(ma_slow, "INDICATOR",color.red)
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
Of course, you can run these types just by adding options. 'ma_select1 ' and 'ma_select2'
SMA', 'EMA', 'WMA', 'HMA', 'JMA', 'KAMA', 'TMA', 'VAMA', 'SMMA', 'DEMA', 'VMA', 'WWMA', 'EMA_NO_LAG', 'TSF', 'ALMA'
MTFindicatorsQuite recently TradingView added the possibility to create and use Libraries in PineScript. With this feature PineScript became higher quality of coding language overnight. Libraries enable splitting your code into multiple files, providing easier access to code reusability.
I was working on a script which included 3000 lines of code, which was recompiling 1:30 min, and recalculating over 1 minute as well. So I split it into 2 parts: main part + library containing "main logic", which I reuse in variety of scripts, but don't change too often. Result? Now recompilation of my main script takes 10 and recalculation 8 seconds!!!. I instantly fell in love with libraries.
Having said that, and being dedicated hater of security() calls, I have decided to publish a library of MTF indicators created with my own approach: "dig into formula". I have explained reasons for such approach in desription to this script:
So this library script will be a set of indicators reaching to higher timeframes. Just include one line at the beginning of the script you are creating:
import Peter_O/MTFindicators/1 as LIB
and then somewhere is the code add this line:
rsimtf=LIB.rsi_mtf(close,5,14)
All of a sudden you have access to rsimtf from 5x higher timeframe without any hassle :)
I start with RSI MTF, next ones will be ADX, Stochastic and some more. I will update this library with them here as well. Feel free to request particular indicators in comments. Maybe PSAR? Maybe Bollinger Bands?
StringtoNumberThis library is used to convert Text type numbers are numbers.
Library "StringtoNumber"
str1 = '12340' , vv = numstrToNum(str1)
numstrToNum()
Example
// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © hapharmonic
//@version=5
indicator("My Script")
import hapharmonic/StringtoNumber/1 as CV
TF = '240'
GETTF = CV.numstrToNum(TF)
L = label.new(bar_index, high, '|| numstrToNum :>> || ' + str.tostring(GETTF), style=label.style_label_down,size=size.large)
label.delete(L )
SessionsInBoxesLibLibrary "SessionsInBoxesLib"
Provides functions calculating the all-time high/low of values.
get_positions()
draw()
FunctionZigZagMultipleMethodsLibrary "FunctionZigZagMultipleMethods"
ZigZag Multiple Methods.
method(idx) Helper methods enumeration.
Parameters:
idx : int, index of method, range 0 to 4.
Returns: string
function(method, value_x, value_y) Multiple method ZigZag.
Parameters:
method : string, default='(MANUAL) Percent price move over X * Y', method for zigzag.
value_x : float, x value in method.
value_y : float, y value in method.
Returns: tuple with:
zigzag float
direction
reverse_line float
realtimeofpivot int
MHCustomSpotTradingLibraryLibrary "MHCustomSpotTradingLibrary"
HMA(float, float)
Parameters:
float : _src price data
float : _length Period
Returns: Hull Moving Average
EHMA(float, float)
Parameters:
float : _src price data
float : _length Period
Returns: EHMA Moving Average
THMA(float, float)
Parameters:
float : _src price data
float : _length Period
Returns: THMA Moving Average
HullMode(string, float, float)
Parameters:
string : modeSwitch Hull type
float : _src price data
float : _length Period
Returns: A Moving Average
start_Dates(int, int, int)
Parameters:
int : year
int : month
int : day
Returns: Start Date
stop_Dates(int, int, int)
Parameters:
int : year
int : month
int : day
Returns: Stop Date
f_print(string, int, int)
Parameters:
string : _text
int : col
int : row
Returns: Nothing
showStats()
greenCandle()
redCandle()
getDecimals()
truncate()
toWhole()
toPips()
getMA()
getEAP()
barsAboveMA()
barsBelowMA()
barsCrossedMA()
getPullbackBarCount()
getBodySize()
getTopWickSize()
getBottomWickSize()
getBodyPercent()
isHammer()
isStar()
isDoji()
isBullishEC()
isBearishEC()
timeFilter()
dateFilter()
dayFilter()
atrFilter()
fillCell()
harmonicpatternsLibrary "harmonicpatterns"
harmonicpatterns: methods required for calculation of harmonic patterns. These are customised to be used in my scripts. But, also simple enough for others to make use of :)
isGartleyPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isGartleyPattern: Checks for harmonic pattern Gartley
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Gartley. False otherwise.
isBatPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isBatPattern: Checks for harmonic pattern Bat
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Bat. False otherwise.
isButterflyPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isButterflyPattern: Checks for harmonic pattern Butterfly
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Butterfly. False otherwise.
isCrabPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isCrabPattern: Checks for harmonic pattern Crab
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Crab. False otherwise.
isDeepCrabPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isDeepCrabPattern: Checks for harmonic pattern DeepCrab
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is DeepCrab. False otherwise.
isCypherPattern(xabRatio, axcRatio, xadRatio, err_min, err_max) isCypherPattern: Checks for harmonic pattern Cypher
Parameters:
xabRatio : AB/XA
axcRatio : XC/AX
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Cypher. False otherwise.
isSharkPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isSharkPattern: Checks for harmonic pattern Shark
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Shark. False otherwise.
isNenStarPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isNenStarPattern: Checks for harmonic pattern Nenstar
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Nenstar. False otherwise.
isAntiNenStarPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiNenStarPattern: Checks for harmonic pattern Anti NenStar
Parameters:
xabRatio : - AB/XA
abcRatio : - BC/AB
bcdRatio : - CD/BC
xadRatio : - AD/XA
err_min : - Minumum error threshold
err_max : - Maximum error threshold
Returns: True if the pattern is Anti NenStar. False otherwise.
isAntiSharkPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiSharkPattern: Checks for harmonic pattern Anti Shark
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Shark. False otherwise.
isAntiCypherPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiCypherPattern: Checks for harmonic pattern Anti Cypher
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Cypher. False otherwise.
isAntiCrabPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiCrabPattern: Checks for harmonic pattern Anti Crab
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Crab. False otherwise.
isAntiBatPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiBatPattern: Checks for harmonic pattern Anti Bat
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Bat. False otherwise.
isAntiGartleyPattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isAntiGartleyPattern: Checks for harmonic pattern Anti Gartley
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Anti Gartley. False otherwise.
isNavarro200Pattern(xabRatio, abcRatio, bcdRatio, xadRatio, err_min, err_max) isNavarro200Pattern: Checks for harmonic pattern Navarro200
Parameters:
xabRatio : AB/XA
abcRatio : BC/AB
bcdRatio : CD/BC
xadRatio : AD/XA
err_min : Minumum error threshold
err_max : Maximum error threshold
Returns: True if the pattern is Navarro200. False otherwise.
isHarmonicPattern(x, a, c, c, d, flags, errorPercent) isHarmonicPattern: Checks for harmonic patterns
Parameters:
x : X coordinate value
a : A coordinate value
c : B coordinate value
c : C coordinate value
d : D coordinate value
flags : flags to check patterns. Send empty array to enable all
errorPercent : Error threshold
Returns: Array of boolean values which says whether valid pattern exist and array of corresponding pattern names
ma_functionLibrary "ma_function"
TODO: This library is a package of various MAs.
ma_function(name, source, length) This function provides the MA specified in the argument.
Parameters:
name : MA's name
source : Source value
length : Look back periods
Returns: Ma value
LocalLimitLibrary "LocalLimit"
Calculates the local upper or local lower limit for a given series. Applying multiple passes produces what appears like support or resistance levels.
See Local Limits for more detail.
upper(src) Produces the recent local upper limit for a given series.
Parameters:
src : The source series to derive from.
lower(src) Produces the recent local lower limit for a given series.
Parameters:
src : The source series to derive from.
SgjoeLibraryLibrary "SgjoeLibrary"
Custom functions
highest_when(float, float) Permits a condition to be used with highest(high,condition)
Parameters:
float : _high_series The High for the condition
float : _when The condition such as close > high
Returns: The high(s) at the point(s) the condition was true
lowest_when(float, float) Permits a condition to be used with lowest(low,condition)
Parameters:
float : _low_series The Low for the condition
float : _when The condition such as close < low
Returns: The low(s) at the point(s) the condition was true
MomentumSignalsLibrary "MomentumSignals"
Contains utilities varying algorithms for detecting key changes in momentum. Note: Momentum is not velocity and should be used in conjunction with other indicators. A change in momentum does not mean a reversal of velocity or trend.
simple(primary, secondary, len) Compares two series for changes in momentum to derive signal values.
Parameters:
primary : The primary series (typically a moving average) to look for changes in momentum.
secondary : The secondary series (typically derived moving average of the primary) to use as a comparison value.
len : The number of bars to measure the change in momentum.
filtered(primary, secondary, len, stdlen, stdMultiple) Compares two series for changes in momentum to derive signal values. Uses statistics to filter out changes in momentum.
Parameters:
primary : The primary series (typically a moving average) to look for changes in momentum.
secondary : The secondary series (typically derived moving average of the primary) to use as a comparison value.
len : The number of bars to measure the change in momentum.
stdlen : The number of bars to measure the change in momentum for filtering.
stdMultiple : The multiple of the change in momentum to use before reversiing.
special(primary, secondary, stdlen, stdMultiple) Compares two series for changes in momentum to derive signal values. Uses statistics to filter out changes in momentum. Does not signal when likely overbought or oversold.
Parameters:
primary : The primary series (typically a moving average) to look for changes in momentum.
secondary : The secondary series (typically derived moving average of the primary) to use as a comparison value.
stdlen : The number of bars to measure the change in momentum for filtering.
stdMultiple : The multiple of the change in momentum to use before reversiing.
MomentumLibrary "Momentum"
Contains utilities varying algorithms for measuring momentum.
simple(fast, slow, src, fastType, slowType) Derives momentum from two moving averages of different lengths.
Parameters:
fast : The length of the fast moving average.
slow : The length of the slow moving average.
src : The series to measure from. Default is 'close'.
fastType : The type of moving average the fast should use. Values allowed are: SMA, EMA, WMA, VWMA and VAWMA.
slowType : The type of moving average the slow should use. Values allowed are: SMA, EMA, WMA, VWMA and VAWMA.
stochRSI(fast, fast, rsiLen, stochLen, src, kmode) Returns the K and D values of a Stochastic RSI. Allows for different moving averages to produce the K value.
Parameters:
fast : The length to average the stochastic.
fast : The length to smooth out K and produce D.
rsiLen : The length of the RSI.
stochLen : The length of stochastic.
src : The series to measure from. Default is 'close'.
kmode : The type of moving average to generate. Values allowed are: SMA, EMA, WMA, VWMA and VAWMA.
Returns:
macd(fast, slow, signal, src, fastType, slowType, slowType) Same as well-known MACD formula but allows for different moving averages types to be used.
Parameters:
fast : The length of the fast moving average.
slow : The length of the slow moving average.
signal : The length of average to applied to smooth out the signal.
src : The series to measure from. Default is 'close'.
fastType : The type of moving average the fast should use. Values allowed are: SMA, EMA, WMA, VWMA and VAWMA.
slowType : The type of moving average the slow should use. Values allowed are: SMA, EMA, WMA, VWMA and VAWMA.
slowType : The type of moving average the signal should use. Values allowed are: SMA, EMA, WMA, VWMA and VAWMA.
Returns:
VolatilityLibrary "Volatility"
Functions for determining if volatility (true range) is within or exceeds normal.
The "True Range" (ta.tr) is used for measuring volatility.
Values are normalized by the volume adjusted weighted moving average (VAWMA) to be more like percent moves than price.
current(len) Returns the current price adjusted volatitlity ratio.
Parameters:
len : Number of bars to get a volume adjusted weighted average price.
normal(len, maxDeviation, level, gapDays, spec, res) Returns the normal upper range of volatility. Compensates for overnight gaps within a regular session.
Parameters:
len : Number of bars to measure volatility.
maxDeviation : The limit of volatility before considered an outlier.
level : The amount of standard deviation after cleaning outliers to be considered within normal.
gapDays : The number of days in the past to measure overnight gap volaility.
spec : session.regular (default), session.extended or other time spec.
res : The resolution (default = '1440').
isNormal(len, maxDeviation, level, gapDays, spec, res) Returns true if the volatility (true range) is within normal levels. Compensates for overnight gaps within a regular session.
Parameters:
len : Number of bars to measure volatility.
maxDeviation : The limit of volatility before considered an outlier.
level : The amount of standard deviation after cleaning outliers to be considered within normal.
gapDays : The number of days in the past to measure overnight gap volaility.
spec : session.regular (default), session.extended or other time spec.
res : The resolution (default = '1440').
severity(len, maxDeviation, level, gapDays, spec, res) Returns ratio of the current value to the normal value. Compensates for overnight gaps within a regular session.
Parameters:
len : Number of bars to measure volatility.
maxDeviation : The limit of volatility before considered an outlier.
level : The amount of standard deviation after cleaning outliers to be considered within normal.
gapDays : The number of days in the past to measure overnight gap volaility.
spec : session.regular (default), session.extended or other time spec.
res : The resolution (default = '1440').
LeoLibraryLibrary "LeoLibrary"
A collection of custom tools & utility functions commonly used with my scripts
getDecimals() Calculates how many decimals are on the quote price of the current market
Returns: The current decimal places on the market quote price
truncate(float, float) Truncates (cuts) excess decimal places
Parameters:
float : _number The number to truncate
float : _decimalPlaces (default=2) The number of decimal places to truncate to
Returns: The given _number truncated to the given _decimalPlaces
toWhole(float) Converts pips into whole numbers
Parameters:
float : _number The pip number to convert into a whole number
Returns: The converted number
toPips(float) Converts whole numbers back into pips
Parameters:
float : _number The whole number to convert into pips
Returns: The converted number
av_getPositionSize(float, float, float, float) Calculates OANDA forex position size for AutoView based on the given parameters
Parameters:
float : _balance The account balance to use
float : _risk The risk percentage amount (as a whole number - eg. 1 = 1% risk)
float : _stopPoints The stop loss distance in POINTS (not pips)
float : _conversionRate The conversion rate of our account balance currency
Returns: The calculated position size (in units - only compatible with OANDA)
getMA(int, string) Gets a Moving Average based on type
Parameters:
int : _length The MA period
string : _maType The type of MA
Returns: A moving average with the given parameters
getEAP(float) Performs EAP stop loss size calculation (eg. ATR >= 20.0 and ATR < 30, returns 20)
Parameters:
float : _atr The given ATR to base the EAP SL calculation on
Returns: The EAP SL converted ATR size
barsAboveMA(int, float) Counts how many candles are above the MA
Parameters:
int : _lookback The lookback period to look back over
float : _ma The moving average to check
Returns: The bar count of how many recent bars are above the MA
barsBelowMA(int, float) Counts how many candles are below the MA
Parameters:
int : _lookback The lookback period to look back over
float : _ma The moving average to reference
Returns: The bar count of how many recent bars are below the EMA
barsCrossedMA(int, float) Counts how many times the EMA was crossed recently
Parameters:
int : _lookback The lookback period to look back over
float : _ma The moving average to reference
Returns: The bar count of how many times price recently crossed the EMA
getPullbackBarCount(int, int) Counts how many green & red bars have printed recently (ie. pullback count)
Parameters:
int : _lookback The lookback period to look back over
int : _direction The color of the bar to count (1 = Green, -1 = Red)
Returns: The bar count of how many candles have retraced over the given lookback & direction
getBodySize() Gets the current candle's body size (in POINTS, divide by 10 to get pips)
Returns: The current candle's body size in POINTS
getTopWickSize() Gets the current candle's top wick size (in POINTS, divide by 10 to get pips)
Returns: The current candle's top wick size in POINTS
getBottomWickSize() Gets the current candle's bottom wick size (in POINTS, divide by 10 to get pips)
Returns: The current candle's bottom wick size in POINTS
getBodyPercent() Gets the current candle's body size as a percentage of its entire size including its wicks
Returns: The current candle's body size percentage
isHammer(float, bool) Checks if the current bar is a hammer candle based on the given parameters
Parameters:
float : _fib (default=0.382) The fib to base candle body on
bool : _colorMatch (default=false) Does the candle need to be green? (true/false)
Returns: A boolean - true if the current bar matches the requirements of a hammer candle
isStar(float, bool) Checks if the current bar is a shooting star candle based on the given parameters
Parameters:
float : _fib (default=0.382) The fib to base candle body on
bool : _colorMatch (default=false) Does the candle need to be red? (true/false)
Returns: A boolean - true if the current bar matches the requirements of a shooting star candle
isDoji(float, bool) Checks if the current bar is a doji candle based on the given parameters
Parameters:
float : _wickSize (default=2) The maximum top wick size compared to the bottom (and vice versa)
bool : _bodySize (default=0.05) The maximum body size as a percentage compared to the entire candle size
Returns: A boolean - true if the current bar matches the requirements of a doji candle
isBullishEC(float, float, bool) Checks if the current bar is a bullish engulfing candle
Parameters:
float : _allowance (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
float : _rejectionWickSize (default=disabled) The maximum rejection wick size compared to the body as a percentage
bool : _engulfWick (default=false) Does the engulfing candle require the wick to be engulfed as well?
Returns: A boolean - true if the current bar matches the requirements of a bullish engulfing candle
isBearishEC(float, float, bool) Checks if the current bar is a bearish engulfing candle
Parameters:
float : _allowance (default=0) How many POINTS to allow the open to be off by (useful for markets with micro gaps)
float : _rejectionWickSize (default=disabled) The maximum rejection wick size compared to the body as a percentage
bool : _engulfWick (default=false) Does the engulfing candle require the wick to be engulfed as well?
Returns: A boolean - true if the current bar matches the requirements of a bearish engulfing candle
timeFilter(string, bool) Determines if the current price bar falls inside the specified session
Parameters:
string : _sess The session to check
bool : _useFilter (default=false) Whether or not to actually use this filter
Returns: A boolean - true if the current bar falls within the given time session
dateFilter(int, int) Determines if this bar's time falls within date filter range
Parameters:
int : _startTime The UNIX date timestamp to begin searching from
int : _endTime the UNIX date timestamp to stop searching from
Returns: A boolean - true if the current bar falls within the given dates
dayFilter(bool, bool, bool, bool, bool, bool, bool) Checks if the current bar's day is in the list of given days to analyze
Parameters:
bool : _monday Should the script analyze this day? (true/false)
bool : _tuesday Should the script analyze this day? (true/false)
bool : _wednesday Should the script analyze this day? (true/false)
bool : _thursday Should the script analyze this day? (true/false)
bool : _friday Should the script analyze this day? (true/false)
bool : _saturday Should the script analyze this day? (true/false)
bool : _sunday Should the script analyze this day? (true/false)
Returns: A boolean - true if the current bar's day is one of the given days
atrFilter(float, float) Checks the current bar's size against the given ATR and max size
Parameters:
float : _atr (default=ATR 14 period) The given ATR to check
float : _maxSize The maximum ATR multiplier of the current candle
Returns: A boolean - true if the current bar's size is less than or equal to _atr x _maxSize
fillCell(table, int, int, string, string, color, color) This updates the given table's cell with the given values
Parameters:
table : _table The table ID to update
int : _column The column to update
int : _row The row to update
string : _title The title of this cell
string : _value The value of this cell
color : _bgcolor The background color of this cell
color : _txtcolor The text color of this cell
Returns: A boolean - true if the current bar falls within the given dates
GenericTALibrary "GenericTA"
What is it?
The real generic library. Which means it is just covering most built-in indicators / functions, but with more parameters, so the user don't have to write more few lines to achieve something simple and replicative.
Development process?
Will tidy it up, and setting up in later stage.
Welcome to inbox me to improve the library ------
If you are finding a similar thing. That's a good news. Because I am making it.
PivotPointsDailyTraditionalLibrary "PivotPointsDailyTraditional"
Provides the traditional daily pivot values and a pivot vacinity function.
P(level, daysPrior) Returns the P value.
Parameters:
level : The level to caclulate.
daysPrior : The number of days in the past to do the calculation.
R(level, daysPrior) Calculates the R value for a given pivot level.
Parameters:
level : The level to caclulate.
daysPrior : The number of days in the past to do the calculation.
S(level, daysPrior) Calculates the S value for a given pivot level.
Parameters:
level : The level to caclulate.
daysPrior : The number of days in the past to do the calculation.
vacinity(value, daysPrior, maxLevel) Returns a value representing where the provided value is in relation to each pivot level.
Parameters:
value : The value to compare against.
daysPrior : The number of days in the past to do the calculation.
maxLevel : The maximum number of pivot levels to include.
DailyLevelsLibrary "DailyLevels"
Functions for acquiring daily timeframe data by number of prior days.
openD(daysPrior, spec, res) Gets the open for the number of days prior.
Parameters:
daysPrior : Number of days back to get the open from.
spec : session.regular (default), session.extended or other time spec.
res : The resolution (default = '1440').
Returns: The open for the number of days prior.
highD(daysPrior, extraForward, spec, res) Gets the highest value for the number of days prior.
Parameters:
daysPrior : Number of days back to get the high from.
extraForward : Number of extra days forward to include.
spec : session.regular (default), session.extended or other time spec.
res : The resolution (default = '1440').
Returns: The high for the number of days prior.
lowD(daysPrior, extraForward, spec, res) Gets the lowest value for the number of days prior.
Parameters:
daysPrior : Number of days back to get the low from.
extraForward : Number of extra days forward to include.
spec : session.regular (default), session.extended or other time spec.
res : The resolution (default = '1440').
Returns: The low for the number of days prior.
closeD(daysPrior, spec, res) Gets the close for the number of days prior.
Parameters:
daysPrior : Number of days back to get the open from. 0 produces the current close
spec : session.regular (default), session.extended or other time spec.
res : The resolution (default = '1440').
Returns: The close for the number of days prior.
hlc3D(daysPrior, extraForward, spec, res) Gets the HLC3 value for the number of days prior.
Parameters:
daysPrior : Number of days back to get the HLC3 from.
extraForward : Number of extra days forward to include. Determines the closing value.
spec : session.regular (default), session.extended or other time spec.
res : The resolution (default = '1440').
Returns: The HLC3 for the number of days prior.
pNRTRLibrary "pNRTR"
Provides functions for calculating Nick Rypock Trailing Reverse (NRTR) trend values with higher precision offsets for both low, and high points rather than the standard single offset.
pnrtr(float low_offset = 0.2, float high_offset = 0.2, float value = close)
low_offset
Offset used for nrtr low_point calculations. Default is 0.2.
high_offset
Offset used for nrtr high_point calculations. Default is 0.2.
value
Variable used for nrtr point calculations. Default is close.