Merge branch 'twopirllc:development' into development

This commit is contained in:
P S Solanki
2021-12-18 19:48:36 +05:30
committed by GitHub
153 changed files with 169 additions and 1586 deletions
+7 -4
View File
File diff suppressed because one or more lines are too long
+3 -2
View File
@@ -80,10 +80,11 @@ Category = {
"natr", "pdist", "rvi", "thermo", "true_range", "ui"
],
# Volume, "vp" or "Volume Profile" is unique
# Volume.
# Note: "vp" or "Volume Profile" is excluded since it does not return a Time Series
"volume": [
"ad", "adosc", "aobv", "cmf", "efi", "eom", "kvo", "mfi", "nvi", "obv",
"pvi", "pvol", "pvr", "pvt"
"pvi", "pvol", "pvr", "pvt", "wb_tsv"
],
}
-11
View File
@@ -13,17 +13,6 @@ def cdl_doji(open_, high, low, close, length=None, factor=None, scalar=None, asi
Sources:
TA-Lib: 96.56% Correlation
Calculation:
Default values:
length=10, percent=10 (0.1), scalar=100
ABS = Absolute Value
SMA = Simple Moving Average
BODY = ABS(close - open)
HL_RANGE = ABS(high - low)
DOJI = scalar IF BODY < 0.01 * percent * SMA(HL_RANGE, length) ELSE 0
Args:
open_ (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
-8
View File
@@ -15,14 +15,6 @@ def cdl_inside(open_, high, low, close, asbool=False, offset=None, **kwargs):
Sources:
https://www.tradingview.com/script/IyIGN1WO-Inside-Bar/
Calculation:
Default Inputs:
asbool=False
inside = (high.diff() < 0) & (low.diff() > 0)
if not asbool:
inside *= candle_color(open_, close)
Args:
open_ (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
-10
View File
@@ -11,16 +11,6 @@ def cdl_z(open_, high, low, close, length=None, full=None, ddof=None, offset=Non
Source: Kevin Johnson
Calculation:
Default values:
length=30, full=False, ddof=1
Z = ZSCORE
open = Z( open, length, ddof)
high = Z( high, length, ddof)
low = Z( low, length, ddof)
close = Z(close, length, ddof)
Args:
open_ (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
-19
View File
@@ -19,25 +19,6 @@ def ha(open_, high, low, close, offset=None, **kwargs):
Sources:
https://www.investopedia.com/terms/h/heikinashi.asp
Calculation:
HA_OPEN[0] = (open[0] + close[0]) / 2
HA_CLOSE = (open[0] + high[0] + low[0] + close[0]) / 4
for i > 1 in df.index:
HA_OPEN = (HA_OPEN[i1] + HA_CLOSE[i1]) / 2
HA_HIGH = MAX(HA_OPEN, HA_HIGH, HA_CLOSE)
HA_LOW = MIN(HA_OPEN, HA_LOW, HA_CLOSE)
How to Calculate Heikin-Ashi
Use one period to create the first Heikin-Ashi (HA) candle, using
the formulas. For example use the high, low, open, and close to
create the first HA close price. Use the open and close to create
the first HA open. The high of the period will be the first HA high,
and the low will be the first HA low. With the first HA calculated,
it is now possible to continue computing the HA candles per the formulas.
Args:
open_ (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
+2 -3
View File
@@ -667,7 +667,6 @@ class AnalysisIndicators(BasePandasObject):
"short_run",
"td_seq", # Performance exclusion
"tsignals",
"vp",
"xsignals",
]
@@ -1834,8 +1833,8 @@ class AnalysisIndicators(BasePandasObject):
result = pvt(close=close, volume=volume, offset=offset, **kwargs)
return self._post_process(result, **kwargs)
def vp(self, width=None, percent=None, **kwargs):
def wb_tsv(self, length=None, signal=None, offset=None, **kwargs):
close = self._get_column(kwargs.pop("close", "close"))
volume = self._get_column(kwargs.pop("volume", "volume"))
result = vp(close=close, volume=volume, width=width, percent=percent, **kwargs)
result = wb_tsv(close=close, volume=volume, signal=signal, offset=offset, **kwargs)
return self._post_process(result, **kwargs)
-3
View File
@@ -36,9 +36,6 @@ def ebsw(close, length=None, bars=None, offset=None, initial_version=False, **kw
- https://www.prorealcode.com/prorealtime-indicators/even-better-sinewave/
- J.F.Ehlers 'Cycle Analytics for Traders', 2014
Calculation:
refer to 'sources' or implementation
Args:
close (pd.Series): Series of 'close's
length (int): It's max cycle/trend period. Values between 40-48 work like
-3
View File
@@ -24,9 +24,6 @@ def reflex(close, length=None, smooth=None, alpha=None, offset=None, **kwargs):
Sources:
https://www.prorealcode.com/prorealtime-indicators/reflex-and-trendflex-indicators-john-f-ehlers/
Calculation:
Refer to provided source or the code above.
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 20
-7
View File
@@ -13,13 +13,6 @@ def ao(high, low, fast=None, slow=None, offset=None, **kwargs):
https://www.tradingview.com/wiki/Awesome_Oscillator_(AO)
https://www.ifcm.co.uk/ntx-indicators/awesome-oscillator
Calculation:
Default Inputs:
fast=5, slow=34
SMA = Simple Moving Average
median = (high + low) / 2
AO = SMA(median, fast) - SMA(median, slow)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-6
View File
@@ -14,12 +14,6 @@ def apo(close, fast=None, slow=None, mamode=None, talib=None, offset=None, **kwa
Sources:
https://www.tradingtechnologies.com/xtrader-help/x-study/technical-indicator-definitions/absolute-price-oscillator-apo/
Calculation:
Default Inputs:
fast=12, slow=26
SMA = Simple Moving Average
APO = SMA(close, fast) - SMA(close, slow)
Args:
close (pd.Series): Series of 'close's
fast (int): The short period. Default: 12
-7
View File
@@ -12,13 +12,6 @@ def bias(close, length=None, mamode=None, offset=None, **kwargs):
Few internet resources on definitive definition.
Request by Github user homily, issue #46
Calculation:
Default Inputs:
length=26, MA='sma'
BIAS = (close - MA(close, length)) / MA(close, length)
= (close / MA(close, length)) - 1
Args:
close (pd.Series): Series of 'close's
length (int): The period. Default: 26
-3
View File
@@ -11,9 +11,6 @@ def bop(open_, high, low, close, scalar=None, talib=None, offset=None, **kwargs)
Sources:
http://www.worden.com/TeleChartHelp/Content/Indicators/Balance_of_Power.htm
Calculation:
BOP = scalar * (close - open) / (high - low)
Args:
open (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
-14
View File
@@ -12,20 +12,6 @@ def brar(open_, high, low, close, length=None, scalar=None, drift=None, offset=N
No internet resources on definitive definition.
Request by Github user homily, issue #46
Calculation:
Default Inputs:
length=26, scalar=100
SUM = Sum
HO_Diff = high - open
OL_Diff = open - low
HCY = high - close[-1]
CYL = close[-1] - low
HCY[HCY < 0] = 0
CYL[CYL < 0] = 0
AR = scalar * SUM(HO, length) / SUM(OL, length)
BR = scalar * SUM(HCY, length) / SUM(CYL, length)
Args:
open_ (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
-10
View File
@@ -14,16 +14,6 @@ def cci(high, low, close, length=None, c=None, talib=None, offset=None, **kwargs
Sources:
https://www.tradingview.com/wiki/Commodity_Channel_Index_(CCI)
Calculation:
Default Inputs:
length=14, c=0.015
SMA = Simple Moving Average
MAD = Mean Absolute Deviation
tp = typical_price = hlc3 = (high + low + close) / 3
mean_tp = SMA(tp, length)
mad_tp = MAD(tp, length)
CCI = (tp - mean_tp) / (c * mad_tp)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-7
View File
@@ -12,13 +12,6 @@ def cfo(close, length=None, scalar=None, drift=None, offset=None, **kwargs):
Sources:
https://www.fmlabs.com/reference/default.htm?url=ForecastOscillator.htm
Calculation:
Default Inputs:
length=9, drift=1, scalar=100
LINREG = Linear Regression
CFO = scalar * (close - LINERREG(length, tdf=True)) / close
Args:
close (pd.Series): Series of 'close's
length (int): The period. Default: 9
-4
View File
@@ -11,10 +11,6 @@ def cg(close, length=None, offset=None, **kwargs):
Sources:
http://www.mesasoftware.com/papers/TheCGOscillator.pdf
Calculation:
Default Inputs:
length=10
Args:
close (pd.Series): Series of 'close's
length (int): The length of the period. Default: 10
-7
View File
@@ -14,13 +14,6 @@ def cmo(close, length=None, scalar=None, talib=None, drift=None, offset=None, **
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/chande-momentum-oscillator-cmo/
https://www.tradingview.com/script/hdrf0fXV-Variable-Index-Dynamic-Average-VIDYA/
Calculation:
Default Inputs:
drift=1, scalar=100
# Same Calculation as RSI except for this step
CMO = scalar * (PSUM - NSUM) / (PSUM + NSUM)
Args:
close (pd.Series): Series of 'close's
scalar (float): How much to magnify. Default: 100
-10
View File
@@ -16,16 +16,6 @@ def coppock(close, length=None, fast=None, slow=None, offset=None, **kwargs):
Sources:
https://en.wikipedia.org/wiki/Coppock_curve
Calculation:
Default Inputs:
length=10, fast=11, slow=14
SMA = Simple Moving Average
MAD = Mean Absolute Deviation
tp = typical_price = hlc3 = (high + low + close) / 3
mean_tp = SMA(tp, length)
mad_tp = MAD(tp, length)
CCI = (tp - mean_tp) / (c * mad_tp)
Args:
close (pd.Series): Series of 'close's
length (int): WMA period. Default: 10
+4
View File
@@ -17,6 +17,10 @@ def cti(close, length=None, offset=None, **kwargs) -> Series:
length (int): It's period. Default: 12
offset (int): How many periods to offset the result. Default: 0
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.Series: Series of the CTI values for the given period.
"""
+4 -16
View File
@@ -16,22 +16,6 @@ def dm(high, low, length=None, mamode=None, talib=None, drift=None, offset=None,
https://www.tradingview.com/pine-script-reference/#fun_dmi
https://www.sierrachart.com/index.php?page=doc/StudiesReference.php&ID=24&Name=Directional_Movement_Index
Calculation:
Default Inputs:
length=14, mamode="rma", drift=1
up = high - high.shift(drift)
dn = low.shift(drift) - low
pos_ = ((up > dn) & (up > 0)) * up
neg_ = ((dn > up) & (dn > 0)) * dn
pos_ = pos_.apply(zero)
neg_ = neg_.apply(zero)
# Not the same values as TA Lib's -+DM
pos = ma(mamode, pos_, length=length)
neg = ma(mamode, neg_, length=length)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
@@ -41,6 +25,10 @@ def dm(high, low, length=None, mamode=None, talib=None, drift=None, offset=None,
drift (int): The difference period. Default: 1
offset (int): How many periods to offset the result. Default: 0
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
Returns:
pd.DataFrame: DMP (+DM) and DMN (-DM) columns.
"""
-10
View File
@@ -13,16 +13,6 @@ def er(close, length=None, drift=None, offset=None, **kwargs):
Sources:
https://help.tc2000.com/m/69404/l/749623-kaufman-efficiency-ratio
Calculation:
Default Inputs:
length=10
ABS = Absolute Value
EMA = Exponential Moving Average
abs_diff = ABS(close.diff(length))
volatility = ABS(close.diff(1))
ER = abs_diff / SUM(volatility, length)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 1
-8
View File
@@ -20,14 +20,6 @@ def eri(high, low, close, length=None, offset=None, **kwargs):
Sources:
https://admiralmarkets.com/education/articles/forex-indicators/bears-and-bulls-power-indicator
Calculation:
Default Inputs:
length=13
EMA = Exponential Moving Average
BULLPOWER = high - EMA(close, length)
BEARPOWER = low - EMA(close, length)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-23
View File
@@ -16,29 +16,6 @@ def fisher(high, low, length=None, signal=None, offset=None, **kwargs):
Sources:
TradingView (Correlation >99%)
Calculation:
Default Inputs:
length=9, signal=1
HL2 = hl2(high, low)
HHL2 = HL2.rolling(length).max()
LHL2 = HL2.rolling(length).min()
HLR = HHL2 - LHL2
HLR[HLR < 0.001] = 0.001
position = ((HL2 - LHL2) / HLR) - 0.5
v = 0
m = high.size
FISHER = [npNaN for _ in range(0, length - 1)] + [0]
for i in range(length, m):
v = 0.66 * position[i] + 0.67 * v
if v < -0.99: v = -0.999
if v > 0.99: v = 0.999
FISHER.append(0.5 * (nplog((1 + v) / (1 - v)) + FISHER[i - 1]))
SIGNAL = FISHER.shift(signal)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-7
View File
@@ -15,13 +15,6 @@ def inertia(close=None, high=None, low=None, length=None, rvi_length=None, scala
Sources:
https://www.investopedia.com/terms/r/relative_vigor_index.asp
Calculation:
Default Inputs:
length=14, ma_length=20
LSQRMA = Least Squares Moving Average
INERTIA = LSQRMA(RVI(length), ma_length)
Args:
open_ (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
-12
View File
@@ -16,18 +16,6 @@ def kdj(high=None, low=None, close=None, length=None, signal=None, offset=None,
https://www.prorealcode.com/prorealtime-indicators/kdj/
https://docs.anychart.com/Stock_Charts/Technical_Indicators/Mathematical_Description#kdj
Calculation:
Default Inputs:
length=9, signal=3
LL = low for last 9 periods
HH = high for last 9 periods
FAST_K = 100 * (close - LL) / (HH - LL)
K = RMA(FAST_K, signal)
D = RMA(K, signal)
J = 3K - 2D
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-14
View File
@@ -13,20 +13,6 @@ def kst(close, roc1=None, roc2=None, roc3=None, roc4=None, sma1=None, sma2=None,
https://www.tradingview.com/wiki/Know_Sure_Thing_(KST)
https://www.incrediblecharts.com/indicators/kst.php
Calculation:
Default Inputs:
roc1=10, roc2=15, roc3=20, roc4=30,
sma1=10, sma2=10, sma3=10, sma4=15, signal=9, drift=1
ROC = Rate of Change
SMA = Simple Moving Average
rocsma1 = SMA(ROC(close, roc1), sma1)
rocsma2 = SMA(ROC(close, roc2), sma2)
rocsma3 = SMA(ROC(close, roc3), sma3)
rocsma4 = SMA(ROC(close, roc4), sma4)
KST = 100 * (rocsma1 + 2 * rocsma2 + 3 * rocsma3 + 4 * rocsma4)
KST_Signal = SMA(KST, signal)
Args:
close (pd.Series): Series of 'close's
roc1 (int): ROC 1 period. Default: 10
-13
View File
@@ -17,19 +17,6 @@ def macd(close, fast=None, slow=None, signal=None, talib=None, offset=None, **kw
https://www.tradingview.com/wiki/MACD_(Moving_Average_Convergence/Divergence)
AS Mode: https://tr.tradingview.com/script/YFlKXHnP/
Calculation:
Default Inputs:
fast=12, slow=26, signal=9
EMA = Exponential Moving Average
MACD = EMA(close, fast) - EMA(close, slow)
Signal = EMA(MACD, signal)
Histogram = MACD - Signal
if asmode:
MACD = MACD - Signal
Signal = EMA(MACD, signal)
Histogram = MACD - Signal
Args:
close (pd.Series): Series of 'close's
fast (int): The short period. Default: 12
-5
View File
@@ -12,11 +12,6 @@ def mom(close, length=None, talib=None, offset=None, **kwargs):
Sources:
http://www.onlinetradingconcepts.com/TechnicalAnalysis/Momentum.html
Calculation:
Default Inputs:
length=1
MOM = close.diff(length)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 1
-9
View File
@@ -14,15 +14,6 @@ def pgo(high, low, close, length=None, offset=None, **kwargs):
Sources:
https://library.tradingtechnologies.com/trade/chrt-ti-pretty-good-oscillator.html
Calculation:
Default Inputs:
length=14
ATR = Average True Range
SMA = Simple Moving Average
EMA = Exponential Moving Average
PGO = (close - SMA(close, length)) / EMA(ATR(high, low, close, length), length)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-11
View File
@@ -14,17 +14,6 @@ def ppo(close, fast=None, slow=None, signal=None, scalar=None, mamode=None, tali
Sources:
https://www.tradingview.com/wiki/MACD_(Moving_Average_Convergence/Divergence)
Calculation:
Default Inputs:
fast=12, slow=26
SMA = Simple Moving Average
EMA = Exponential Moving Average
fast_sma = SMA(close, fast)
slow_sma = SMA(close, slow)
PPO = 100 * (fast_sma - slow_sma) / slow_sma
Signal = EMA(PPO, signal)
Histogram = PPO - Signal
Args:
close(pandas.Series): Series of 'close's
fast(int): The short period. Default: 12
-14
View File
@@ -14,20 +14,6 @@ def psl(close, open_=None, length=None, scalar=None, drift=None, offset=None, **
Sources:
https://www.quantshare.com/item-851-psychological-line
Calculation:
Default Inputs:
length=12, scalar=100, drift=1
IF NOT open:
DIFF = SIGN(close - close[drift])
ELSE:
DIFF = SIGN(close - open)
DIFF.fillna(0)
DIFF[DIFF <= 0] = 0
PSL = scalar * SUM(DIFF, length) / length
Args:
close (pd.Series): Series of 'close's
open_ (pd.Series, optional): Series of 'open's
-9
View File
@@ -12,15 +12,6 @@ def pvo(volume, fast=None, slow=None, signal=None, scalar=None, offset=None, **k
Sources:
https://www.fmlabs.com/reference/default.htm?url=PVO.htm
Calculation:
Default Inputs:
fast=12, slow=26, signal=9
EMA = Exponential Moving Average
PVO = (EMA(volume, fast) - EMA(volume, slow)) / EMA(volume, slow)
Signal = EMA(PVO, signal)
Histogram = PVO - Signal
Args:
volume (pd.Series): Series of 'volume's
fast (int): The short period. Default: 12
-4
View File
@@ -21,10 +21,6 @@ def qqe(close, length=None, smooth=None, factor=None, mamode=None, drift=None, o
https://www.tradingpedia.com/forex-trading-indicators/quantitative-qualitative-estimation
https://www.prorealcode.com/prorealtime-indicators/qqe-quantitative-qualitative-estimation/
Calculation:
Default Inputs:
length=14, smooth=5, factor=4.236, mamode="ema", drift=1
Args:
close (pd.Series): Series of 'close's
length (int): RSI period. Default: 14
-6
View File
@@ -14,12 +14,6 @@ def roc(close, length=None, scalar=None, talib=None, offset=None, **kwargs):
Sources:
https://www.tradingview.com/wiki/Rate_of_Change_(ROC)
Calculation:
Default Inputs:
length=1
MOM = Momentum
ROC = 100 * MOM(close, length) / close.shift(length)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 1
-15
View File
@@ -14,21 +14,6 @@ def rsi(close, length=None, scalar=None, talib=None, drift=None, offset=None, **
Sources:
https://www.tradingview.com/wiki/Relative_Strength_Index_(RSI)
Calculation:
Default Inputs:
length=14, scalar=100, drift=1
ABS = Absolute Value
RMA = Rolling Moving Average
diff = close.diff(drift)
positive = diff if diff > 0 else 0
negative = diff if diff < 0 else 0
pos_avg = RMA(positive, length)
neg_avg = ABS(RMA(negative, length))
RSI = scalar * pos_avg / (pos_avg + neg_avg)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 14
-3
View File
@@ -17,9 +17,6 @@ def rsx(close, length=None, drift=None, offset=None, **kwargs):
http://www.jurikres.com/catalog1/ms_rsx.htm
https://www.prorealcode.com/prorealtime-indicators/jurik-rsx/
Calculation:
Refer to the sources above for information as well as code example.
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 14
-8
View File
@@ -15,14 +15,6 @@ def rvgi(open_, high, low, close, length=None, swma_length=None, offset=None, **
Sources:
https://www.investopedia.com/terms/r/relative_vigor_index.asp
Calculation:
Default Inputs:
length=14, swma_length=4
SWMA = Symmetrically Weighted Moving Average
numerator = SUM(SWMA(close - open, swma_length), length)
denominator = SUM(SWMA(high - low, swma_length), length)
RVGI = numerator / denominator
Args:
open_ (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
+3 -3
View File
@@ -24,12 +24,12 @@ def slope( close, length=None, as_angle=None, to_degrees=None, vertical=None, of
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 1
length (int): It's period. Default: 1
as_angle (value, optional): Converts slope to an angle. Default: False
to_degrees (value, optional): Converts slope angle to degrees. Default: False
offset (int): How many periods to offset the result. Default: 0
Kwargs:
as_angle (value, optional): Converts slope to an angle. Default: False
to_degrees (value, optional): Converts slope angle to degrees. Default: False
fillna (value, optional): pd.DataFrame.fillna(value)
fill_method (value, optional): Type of fill method
-10
View File
@@ -21,16 +21,6 @@ def smi(close, fast=None, slow=None, signal=None, scalar=None, offset=None, **kw
https://www.tradingview.com/script/Xh5Q0une-SMI-Ergodic-Oscillator/
https://www.tradingview.com/script/cwrgy4fw-SMIIO/
Calculation:
Default Inputs:
fast=5, slow=20, signal=5
TSI = True Strength Index
EMA = Exponential Moving Average
ERG = TSI(close, fast, slow)
Signal = EMA(ERG, signal)
OSC = ERG - Signal
Args:
close (pd.Series): Series of 'close's
fast (int): The short period. Default: 5
-31
View File
@@ -24,37 +24,6 @@ def squeeze(high, low, close, bb_length=None, bb_std=None, kc_length=None, kc_sc
https://www.tradingview.com/scripts/lazybear/
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/T-U/TTM-Squeeze
Calculation:
Default Inputs:
bb_length=20, bb_std=2, kc_length=20, kc_scalar=1.5, mom_length=12,
mom_smooth=12, tr=True, lazybear=False,
BB = Bollinger Bands
KC = Keltner Channels
MOM = Momentum
SMA = Simple Moving Average
EMA = Exponential Moving Average
TR = True Range
RANGE = TR(high, low, close) if using_tr else high - low
BB_LOW, BB_MID, BB_HIGH = BB(close, bb_length, std=bb_std)
KC_LOW, KC_MID, KC_HIGH = KC(high, low, close, kc_length, kc_scalar, TR)
if lazybear:
HH = high.rolling(kc_length).max()
LL = low.rolling(kc_length).min()
AVG = 0.25 * (HH + LL) + 0.5 * KC_MID
SQZ = linreg(close - AVG, kc_length)
else:
MOMO = MOM(close, mom_length)
if mamode == "ema":
SQZ = EMA(MOMO, mom_smooth)
else:
SQZ = EMA(momo, mom_smooth)
SQZ_ON = (BB_LOW > KC_LOW) and (BB_HIGH < KC_HIGH)
SQZ_OFF = (BB_LOW < KC_LOW) and (BB_HIGH > KC_HIGH)
NO_SQZ = !SQZ_ON and !SQZ_OFF
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-30
View File
@@ -24,36 +24,6 @@ def squeeze_pro(high, low, close, bb_length=None, bb_std=None, kc_length=None, k
https://usethinkscript.com/threads/john-carters-squeeze-pro-indicator-for-thinkorswim-free.4021/
https://www.tradingview.com/script/TAAt6eRX-Squeeze-PRO-Indicator-Makit0/
Calculation:
Default Inputs:
bb_length=20, bb_std=2, kc_length=20, kc_scalar_wide=2,
kc_scalar_normal=1.5, kc_scalar_narrow=1, mom_length=12,
mom_smooth=6, tr=True,
BB = Bollinger Bands
KC = Keltner Channels
MOM = Momentum
SMA = Simple Moving Average
EMA = Exponential Moving Average
TR = True Range
RANGE = TR(high, low, close) if using_tr else high - low
BB_LOW, BB_MID, BB_HIGH = BB(close, bb_length, std=bb_std)
KC_LOW_WIDE, KC_MID_WIDE, KC_HIGH_WIDE = KC(high, low, close, kc_length, kc_scalar_wide, TR)
KC_LOW_NORMAL, KC_MID_NORMAL, KC_HIGH_NORMAL = KC(high, low, close, kc_length, kc_scalar_normal, TR)
KC_LOW_NARROW, KC_MID_NARROW, KC_HIGH_NARROW = KC(high, low, close, kc_length, kc_scalar_narrow, TR)
MOMO = MOM(close, mom_length)
if mamode == "ema":
SQZPRO = EMA(MOMO, mom_smooth)
else:
SQZPRO = EMA(momo, mom_smooth)
SQZPRO_ON_WIDE = (BB_LOW > KC_LOW_WIDE) and (BB_HIGH < KC_HIGH_WIDE)
SQZPRO_ON_NORMAL = (BB_LOW > KC_LOW_NORMAL) and (BB_HIGH < KC_HIGH_NORMAL)
SQZPRO_ON_NARROW = (BB_LOW > KC_LOW_NARROW) and (BB_HIGH < KC_HIGH_NARROW)
SQZPRO_OFF_WIDE = (BB_LOW < KC_LOW_WIDE) and (BB_HIGH > KC_HIGH_WIDE)
SQZPRO_NO = !SQZ_ON_WIDE and !SQZ_OFF_WIDE
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-7
View File
@@ -26,17 +26,10 @@ def stc(close, tclength=None, fast=None, slow=None, factor=None, offset=None, **
The same goes for osc=, which allows the input of an externally calculated oscillator, overriding ma1 & ma2.
Sources:
Implemented by rengel8 based on work found here:
https://www.prorealcode.com/prorealtime-indicators/schaff-trend-cycle2/
Calculation:
STCmacd = Moving Average Convergance/Divergance or Oscillator
STCstoch = Intermediate Stochastic of MACD/Osc.
2nd Stochastic including filtering with results in the
STC = Schaff Trend Cycle
Args:
close (pd.Series): Series of 'close's, used for indexing Series, mandatory
tclen (int): SchaffTC Signal-Line length. Default: 10 (adjust to the half of cycle)
+17 -19
View File
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from pandas import DataFrame
from pandas_ta import Imports
from pandas_ta.overlap import ma
from pandas_ta.utils import get_offset, non_zero_range, verify_series
from pandas_ta.utils import get_offset, non_zero_range, tal_ma, verify_series
def stoch(high, low, close, k=None, d=None, smooth_k=None, mamode=None, offset=None, **kwargs):
def stoch(high, low, close, k=None, d=None, smooth_k=None, mamode=None, talib=None, offset=None, **kwargs):
"""Stochastic (STOCH)
The Stochastic Oscillator (STOCH) was developed by George Lane in the 1950's.
@@ -20,17 +21,6 @@ def stoch(high, low, close, k=None, d=None, smooth_k=None, mamode=None, offset=N
https://www.tradingview.com/wiki/Stochastic_(STOCH)
https://www.sierrachart.com/index.php?page=doc/StudiesReference.php&ID=332&Name=KD_-_Slow
Calculation:
Default Inputs:
k=14, d=3, smooth_k=3
SMA = Simple Moving Average
LL = low for last k periods
HH = high for last k periods
STOCH = 100 * (close - LL) / (HH - LL)
STOCHk = SMA(STOCH, smooth_k)
STOCHd = SMA(FASTK, d)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
@@ -39,6 +29,8 @@ def stoch(high, low, close, k=None, d=None, smooth_k=None, mamode=None, offset=N
d (int): The Slow %D period. Default: 3
smooth_k (int): The Slow %K period. Default: 3
mamode (str): See ```help(ta.ma)```. Default: 'sma'
talib (bool): If TA Lib is installed and talib is True, Returns the TA Lib
version. Default: True
offset (int): How many periods to offset the result. Default: 0
Kwargs:
@@ -58,18 +50,24 @@ def stoch(high, low, close, k=None, d=None, smooth_k=None, mamode=None, offset=N
close = verify_series(close, _length)
offset = get_offset(offset)
mamode = mamode if isinstance(mamode, str) else "sma"
mode_tal = bool(talib) if isinstance(talib, bool) else True
if high is None or low is None or close is None: return
# Calculate Result
lowest_low = low.rolling(k).min()
highest_high = high.rolling(k).max()
if Imports["talib"] and mode_tal:
from talib import STOCH
stoch_ = STOCH(high, low, close, k, d, tal_ma(mamode), d, tal_ma(mamode))
stoch_k, stoch_d = stoch_[0], stoch_[1]
else:
lowest_low = low.rolling(k).min()
highest_high = high.rolling(k).max()
stoch = 100 * (close - lowest_low)
stoch /= non_zero_range(highest_high, lowest_low)
stoch = 100 * (close - lowest_low)
stoch /= non_zero_range(highest_high, lowest_low)
stoch_k = ma(mamode, stoch.loc[stoch.first_valid_index():,], length=smooth_k)
stoch_d = ma(mamode, stoch_k.loc[stoch_k.first_valid_index():,], length=d)
stoch_k = ma(mamode, stoch.loc[stoch.first_valid_index():,], length=smooth_k)
stoch_d = ma(mamode, stoch_k.loc[stoch_k.first_valid_index():,], length=d)
# Offset
if offset != 0:
-10
View File
@@ -16,16 +16,6 @@ def stochf(high, low, close, k=None, d=None, mamode=None, talib=None, offset=Non
https://www.sierrachart.com/index.php?page=doc/StudiesReference.php&ID=333&Name=KD_-_Fast
https://corporatefinanceinstitute.com/resources/knowledge/trading-investing/fast-stochastic-indicator/
Calculation:
Default Inputs:
k=14, d=3, mamode="sma",
SMA = Simple Moving Average
LL = low for last k periods
HH = high for last k periods
STOCHFk = 100 * (close - LL) / (HH - LL)
STOCHFd = MA(SMA, STOCH, d)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-14
View File
@@ -18,20 +18,6 @@ def stochrsi(close, length=None, rsi_length=None, k=None, d=None, mamode=None, o
Sources:
https://www.tradingview.com/wiki/Stochastic_(STOCH)
Calculation:
Default Inputs:
length=14, rsi_length=14, k=3, d=3
RSI = Relative Strength Index
SMA = Simple Moving Average
RSI = RSI(high, low, close, rsi_length)
LL = lowest RSI for last rsi_length periods
HH = highest RSI for last rsi_length periods
STOCHRSI = 100 * (RSI - LL) / (HH - LL)
STOCHRSIk = SMA(STOCHRSI, k)
STOCHRSId = SMA(STOCHRSIk, d)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-5
View File
@@ -14,11 +14,6 @@ def td_seq(close, asint=None, offset=None, **kwargs):
Sources:
https://tradetrekker.wordpress.com/tdsequential/
Calculation:
Compare current close price with 4 days ago price, up to 13 days. For the
consecutive ascending or descending price sequence, display 6th to 9th day
value.
Args:
close (pd.Series): Series of 'close's
asint (bool): If True, fillnas with 0 and change type to int. Default: False
-10
View File
@@ -12,16 +12,6 @@ def trix(close, length=None, signal=None, scalar=None, drift=None, offset=None,
Sources:
https://www.tradingview.com/wiki/TRIX
Calculation:
Default Inputs:
length=18, drift=1
EMA = Exponential Moving Average
ROC = Rate of Change
ema1 = EMA(close, length)
ema2 = EMA(ema1, length)
ema3 = EMA(ema2, length)
TRIX = 100 * ROC(ema3, drift)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 18
-15
View File
@@ -14,21 +14,6 @@ def tsi(close, fast=None, slow=None, signal=None, scalar=None, mamode=None, drif
Sources:
https://www.investopedia.com/terms/t/tsi.asp
Calculation:
Default Inputs:
fast=13, slow=25, signal=13, scalar=100, drift=1
EMA = Exponential Moving Average
diff = close.diff(drift)
slow_ema = EMA(diff, slow)
fast_slow_ema = EMA(slow_ema, slow)
abs_diff_slow_ema = absolute_diff_ema = EMA(ABS(diff), slow)
abema = abs_diff_fast_slow_ema = EMA(abs_diff_slow_ema, fast)
TSI = scalar * fast_slow_ema / abema
Signal = EMA(TSI, signal)
Args:
close (pd.Series): Series of 'close's
fast (int): The short period. Default: 13
-18
View File
@@ -13,24 +13,6 @@ def uo(high, low, close, fast=None, medium=None, slow=None, fast_w=None, medium_
Sources:
https://www.tradingview.com/wiki/Ultimate_Oscillator_(UO)
Calculation:
Default Inputs:
fast=7, medium=14, slow=28,
fast_w=4.0, medium_w=2.0, slow_w=1.0, drift=1
min_low_or_pc = close.shift(drift).combine(low, min)
max_high_or_pc = close.shift(drift).combine(high, max)
bp = buying pressure = close - min_low_or_pc
tr = true range = max_high_or_pc - min_low_or_pc
fast_avg = SUM(bp, fast) / SUM(tr, fast)
medium_avg = SUM(bp, medium) / SUM(tr, medium)
slow_avg = SUM(bp, slow) / SUM(tr, slow)
total_weight = fast_w + medium_w + slow_w
weights = (fast_w * fast_avg) + (medium_w * medium_avg) + (slow_w * slow_avg)
UO = 100 * weights / total_weight
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-8
View File
@@ -12,14 +12,6 @@ def willr(high, low, close, length=None, talib=None, offset=None, **kwargs):
Sources:
https://www.tradingview.com/wiki/Williams_%25R_(%25R)
Calculation:
Default Inputs:
length=20
LL = low.rolling(length).min()
HH = high.rolling(length).max()
WILLR = 100 * ((close - LL) / (HH - LL) - 1)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-9
View File
@@ -20,15 +20,6 @@ def alligator(close, jaw=None, teeth=None, lips=None, talib=None, offset=None, *
https://www.tradingview.com/scripts/alligator/
https://www.sierrachart.com/index.php?page=doc/StudiesReference.php&ID=175&Name=Bill_Williams_Alligator
Calculation:
Default Inputs:
jaw=13, teeth=8, lips=5, mamode="sma"
SMMA = SMoothed Moving Average
JAW = SMMA(close, jaw)
TEETH = SMMA(close, teeth)
LIPS = SMMA(close, lips)
Args:
close (pd.Series): Series of 'close's
jaw (int): The Jaw period. Default: 13
-8
View File
@@ -24,14 +24,6 @@ def alma(close, length=None, sigma=None, dist_offset=None, offset=None, **kwargs
https://www.sierrachart.com/index.php?page=doc/StudiesReference.php&ID=475&Name=Moving_Average_-_Arnaud_Legoux
https://www.prorealcode.com/prorealtime-indicators/alma-arnaud-legoux-moving-average/
Calculation:
length=9, sigma=6.0, dist_offset=0.85
X = [0, 1, ..., length - 1]
WEIGHTS = e^(-0.5 * (X - FLOOR(dist_offset(length - 1)))^2 / (length / sigma)^2)
ALMA = close.rolling(length).apply(WEIGHTS)
Args:
close (pd.Series): Series of 'close's
length (int): It's period, window size. Default: 9
-9
View File
@@ -13,15 +13,6 @@ def dema(close, length=None, talib=None, offset=None, **kwargs):
Sources:
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/double-exponential-moving-average-dema/
Calculation:
Default Inputs:
length=10
EMA = Exponential Moving Average
ema1 = EMA(close, length)
ema2 = EMA(ema1, length)
DEMA = 2 * ema1 - ema2
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-9
View File
@@ -17,15 +17,6 @@ def ema(close, length=None, talib=None, offset=None, **kwargs):
https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages
https://www.investopedia.com/ask/answers/122314/what-exponential-moving-average-ema-formula-and-how-ema-calculated.asp
Calculation:
Default Inputs:
length=10, adjust=False, sma=True
if sma:
sma_nth = close[0:length].sum() / length
close[:length - 1] = np.NaN
close.iloc[length - 1] = sma_nth
EMA = close.ewm(span=length, adjust=adjust).mean()
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-12
View File
@@ -10,18 +10,6 @@ def fwma(close, length=None, asc=None, offset=None, **kwargs):
Source: Kevin Johnson
Calculation:
Default Inputs:
length=10,
def weights(w):
def _compute(x):
return np.dot(w * x)
return _compute
fibs = utils.fibonacci(length - 1)
FWMA = close.rolling(length)_.apply(weights(fibs), raw=True)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-27
View File
@@ -23,33 +23,6 @@ def hilo(high, low, close, high_length=None, low_length=None, mamode=None, offse
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/simple-moving-average-sma/
https://www.tradingview.com/script/XNQSLIYb-Gann-High-Low/
Calculation:
Default Inputs:
high_length=13, low_length=21, mamode="sma"
EMA = Exponential Moving Average
HMA = Hull Moving Average
SMA = Simple Moving Average # Default
if "ema":
high_ma = EMA(high, high_length)
low_ma = EMA(low, low_length)
elif "hma":
high_ma = HMA(high, high_length)
low_ma = HMA(low, low_length)
else: # "sma"
high_ma = SMA(high, high_length)
low_ma = SMA(low, low_length)
# Similar to Supertrend MA selection
hilo = Series(npNaN, index=close.index)
for i in range(1, m):
if close.iloc[i] > high_ma.iloc[i - 1]:
hilo.iloc[i] = low_ma.iloc[i]
elif close.iloc[i] < low_ma.iloc[i - 1]:
hilo.iloc[i] = high_ma.iloc[i]
else:
hilo.iloc[i] = hilo.iloc[i - 1]
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
+2 -2
View File
@@ -5,12 +5,12 @@ from pandas_ta.utils import get_offset, verify_series
def hl2(high, low, offset=None, **kwargs):
"""HL2
Calculation:
HL2 = 0.5 * (high + low)
HL2 is the midpoint/average of high and low.
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
offset (int): How many periods to offset the result. Default: 0
Returns:
pd.Series: New feature generated.
+2 -2
View File
@@ -6,13 +6,13 @@ from pandas_ta.utils import get_offset, verify_series
def hlc3(high, low, close, talib=None, offset=None, **kwargs):
"""HLC3
Calculation:
HLC3 = (high + low + close) / 3.0
HLC3 is the average of high, low and close.
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
close (pd.Series): Series of 'close's
offset (int): How many periods to offset the result. Default: 0
Returns:
pd.Series: New feature generated.
-11
View File
@@ -13,17 +13,6 @@ def hma(close, length=None, offset=None, **kwargs):
Sources:
https://alanhull.com/hull-moving-average
Calculation:
Default Inputs:
length=10
WMA = Weighted Moving Average
half_length = int(0.5 * length)
sqrt_length = int(sqrt(length))
wmaf = WMA(close, half_length)
wmas = WMA(close, length)
HMA = WMA(2 * wmaf - wmas, sqrt_length)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
+1 -8
View File
@@ -16,19 +16,12 @@ def hwma(close, na=None, nb=None, nc=None, offset=None, **kwargs):
Sources:
https://www.mql5.com/en/code/20856
Calculation:
HWMA[i] = F[i] + V[i] + 0.5 * A[i]
where..
F[i] = (1-na) * (F[i-1] + V[i-1] + 0.5 * A[i-1]) + na * Price[i]
V[i] = (1-nb) * (V[i-1] + A[i-1]) + nb * (F[i] - F[i-1])
A[i] = (1-nc) * A[i-1] + nc * (V[i] - V[i-1])
Args:
close (pd.Series): Series of 'close's
na (float): Smoothed series parameter (from 0 to 1). Default: 0.2
nb (float): Trend parameter (from 0 to 1). Default: 0.1
nc (float): Seasonality parameter (from 0 to 1). Default: 0.1
close (pd.Series): Series of 'close's
offset (int): How many periods to offset the result. Default: 0
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
-14
View File
@@ -12,20 +12,6 @@ def ichimoku(high, low, close, tenkan=None, kijun=None, senkou=None, include_chi
Sources:
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/ichimoku-ich/
Calculation:
Default Inputs:
tenkan=9, kijun=26, senkou=52
MIDPRICE = Midprice
TENKAN_SEN = MIDPRICE(high, low, close, length=tenkan)
KIJUN_SEN = MIDPRICE(high, low, close, length=kijun)
CHIKOU_SPAN = close.shift(-kijun)
SPAN_A = 0.5 * (TENKAN_SEN + KIJUN_SEN)
SPAN_A = SPAN_A.shift(kijun)
SPAN_B = MIDPRICE(high, low, close, length=senkou)
SPAN_B = SPAN_B.shift(kijun)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
+1 -5
View File
@@ -20,10 +20,6 @@ def jma(close, length=None, phase=None, offset=None, **kwargs):
https://c.mql5.com/forextsd/forum/164/jurik_1.pdf
https://www.prorealcode.com/prorealtime-indicators/jurik-volatility-bands/
Calculation:
Default Inputs:
length=7, phase=0
Args:
close (pd.Series): Series of 'close's
length (int): Period of calculation. Default: 7
@@ -99,8 +95,8 @@ def jma(close, length=None, phase=None, offset=None, **kwargs):
jma[i] = jma[i-1] + det1
# Remove initial lookback data and convert to pandas frame
jma[0:_length - 1] = npNaN
jma = Series(jma, index=close.index)
jma.iloc[0:_length - 1] = npNaN
# Offset
if offset != 0:
-4
View File
@@ -18,10 +18,6 @@ def kama(close, length=None, fast=None, slow=None, mamode=None, drift=None, offs
https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:kaufman_s_adaptive_moving_average
https://www.tradingview.com/script/wZGOIz9r-REPOST-Indicators-3-Different-Adaptive-Moving-Averages/
Calculation:
Default Inputs:
length=10
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-19
View File
@@ -18,25 +18,6 @@ def linreg(close, length=None, talib=None, offset=None, **kwargs):
Source: TA Lib
Calculation:
Default Inputs:
length=14
x = [1, 2, ..., n]
x_sum = 0.5 * length * (length + 1)
x2_sum = length * (length + 1) * (2 * length + 1) / 6
divisor = length * x2_sum - x_sum * x_sum
lr(series):
y_sum = series.sum()
y2_sum = (series* series).sum()
xy_sum = (x * series).sum()
m = (length * xy_sum - x_sum * y_sum) / divisor
b = (y_sum * x2_sum - x_sum * xy_sum) / divisor
return m * (length - 1) + b
linreg = close.rolling(length).apply(lr)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
+1 -14
View File
@@ -16,24 +16,11 @@ def mcgd(close, length=None, offset=None, c=None, **kwargs):
Sources:
https://www.investopedia.com/articles/forex/09/mcginley-dynamic-indicator.asp
Calculation:
Default Inputs:
length=10
offset=0
c=1
def mcg_(series):
denom = (constant * length * (series.iloc[1] / series.iloc[0]) ** 4)
series.iloc[1] = (series.iloc[0] + ((series.iloc[1] - series.iloc[0]) / denom))
return series.iloc[1]
mcg_cell = close[0:].rolling(2, min_periods=2).apply(mcg_, raw=False)
mcg_ds = close[:1].append(mcg_cell[1:])
Args:
close (pd.Series): Series of 'close's
length (int): Indicator's period. Default: 10
offset (int): Number of periods to offset the result. Default: 0
c (float): Multiplier for the denominator, sometimes set to 0.6. Default: 1
offset (int): Number of periods to offset the result. Default: 0
Kwargs:
fillna (value, optional): pd.DataFrame.fillna(value)
-9
View File
@@ -8,15 +8,6 @@ def midpoint(close, length=None, talib=None, offset=None, **kwargs):
The Midpoint is the average of the rolling high and low of period length.
Sources:
Calculation:
Default Inputs:
length=2
HC = close.rolling(length).max()
LC = close.rolling(length).min()
MID = 0.5 * (HC + LC)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 2
-9
View File
@@ -8,15 +8,6 @@ def midprice(high, low, length=None, talib=None, offset=None, **kwargs):
The Midprice is the average of the rolling high and low of period length.
Sources:
Calculation:
Default Inputs:
length=2
HH = high.rolling(length).max()
LL = low.rolling(length).min()
MID = 0.5 * (HH + LL)
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
+2 -2
View File
@@ -5,14 +5,14 @@ from pandas_ta.utils import get_offset, verify_series
def ohlc4(open_, high, low, close, offset=None, **kwargs):
"""OHLC4
Calculation:
OHLC4 = 0.25 * (open + high + low + close)
OHLC4 is the average of open, high, low and close.
Args:
open_ (pd.Series): Series of 'open's
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
close (pd.Series): Series of 'close's
offset (int): How many periods to offset the result. Default: 0
Returns:
pd.Series: New feature generated.
-12
View File
@@ -10,18 +10,6 @@ def pwma(close, length=None, asc=None, offset=None, **kwargs):
Source: Kevin Johnson
Calculation:
Default Inputs:
length=10
def weights(w):
def _compute(x):
return np.dot(w * x)
return _compute
triangle = utils.pascals_triangle(length + 1)
PWMA = close.rolling(length)_.apply(weights(triangle), raw=True)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-7
View File
@@ -12,13 +12,6 @@ def rma(close, length=None, offset=None, **kwargs):
https://tlc.thinkorswim.com/center/reference/Tech-Indicators/studies-library/V-Z/WildersSmoothing
https://www.incrediblecharts.com/indicators/wilder_moving_average.php
Calculation:
Default Inputs:
length=10
EMA = Exponential Moving Average
alpha = 1 / length
RMA = EMA(close, alpha=alpha)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-13
View File
@@ -15,19 +15,6 @@ def sinwma(close, length=None, offset=None, **kwargs):
https://www.tradingview.com/script/6MWFvnPO-Sine-Weighted-Moving-Average/
Author: Everget (https://www.tradingview.com/u/everget/)
Calculation:
Default Inputs:
length=10
def weights(w):
def _compute(x):
return np.dot(w * x)
return _compute
sines = Series([sin((i + 1) * pi / (length + 1)) for i in range(0, length)])
w = sines / sines.sum()
SINWMA = close.rolling(length, min_periods=length).apply(weights(w), raw=True)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-5
View File
@@ -12,11 +12,6 @@ def sma(close, length=None, talib=None, offset=None, **kwargs):
Sources:
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/simple-moving-average-sma/
Calculation:
Default Inputs:
length=10
SMA = SUM(close, length) / length
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
+1 -9
View File
@@ -20,14 +20,6 @@ def smma(close, length=None, mamode=None, talib=None, offset=None, **kwargs):
https://www.tradingview.com/scripts/smma/
https://www.sierrachart.com/index.php?page=doc/StudiesReference.php&ID=173&Name=Moving_Average_-_Smoothed
Calculation:
Default Inputs:
length=10, mamode="sma"
MA = Moving Average
SMMA[0:length] = MA(mamode, close, length)
SMMA[:length] = ((length - 1) * SMMA[i] + close[i]) / length
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
@@ -57,7 +49,7 @@ def smma(close, length=None, mamode=None, talib=None, offset=None, **kwargs):
m = close.size
smma = close.copy()
smma[:length - 1] = npNaN
smma.iloc[length - 1] = ma(mamode, close[0:length], length=length, talib=mode_tal)[-1]
smma.iloc[length - 1] = ma(mamode, close[0:length], length=length, talib=mode_tal).iloc[-1]
for i in range(length, m):
smma.iloc[i] = ((length - 1) * smma.iloc[i - 1] + smma.iloc[i]) / length
-6
View File
@@ -24,12 +24,6 @@ def ssf(close, length=None, poles=None, offset=None, **kwargs):
https://www.mql5.com/en/code/588
https://www.mql5.com/en/code/589
Calculation:
Default Inputs:
length=10, poles=[2, 3]
See the source code or Sources listed above.
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-25
View File
@@ -16,31 +16,6 @@ def supertrend(high, low, close, length=None, multiplier=None, offset=None, **kw
Sources:
http://www.freebsensetips.com/blog/detail/7/What-is-supertrend-indicator-its-calculation
Calculation:
Default Inputs:
length=7, multiplier=3.0
Default Direction:
Set to +1 or bullish trend at start
MID = multiplier * ATR
LOWERBAND = HL2 - MID
UPPERBAND = HL2 + MID
if UPPERBAND[i] < FINAL_UPPERBAND[i-1] and close[i-1] > FINAL_UPPERBAND[i-1]:
FINAL_UPPERBAND[i] = UPPERBAND[i]
else:
FINAL_UPPERBAND[i] = FINAL_UPPERBAND[i-1])
if LOWERBAND[i] > FINAL_LOWERBAND[i-1] and close[i-1] < FINAL_LOWERBAND[i-1]:
FINAL_LOWERBAND[i] = LOWERBAND[i]
else:
FINAL_LOWERBAND[i] = FINAL_LOWERBAND[i-1])
if close[i] <= FINAL_UPPERBAND[i]:
SUPERTREND[i] = FINAL_UPPERBAND[i]
else:
SUPERTREND[i] = FINAL_LOWERBAND[i]
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-12
View File
@@ -13,18 +13,6 @@ def swma(close, length=None, asc=None, offset=None, **kwargs):
Source:
https://www.tradingview.com/study-script-reference/#fun_swma
Calculation:
Default Inputs:
length=10
def weights(w):
def _compute(x):
return np.dot(w * x)
return _compute
triangle = utils.symmetric_triangle(length - 1)
SWMA = close.rolling(length)_.apply(weights(triangle), raw=True)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-16
View File
@@ -13,22 +13,6 @@ def t3(close, length=None, a=None, talib=None, offset=None, **kwargs):
Sources:
http://www.binarytribune.com/forex-trading-indicators/t3-moving-average-indicator/
Calculation:
Default Inputs:
length=10, a=0.7
c1 = -a^3
c2 = 3a^2 + 3a^3 = 3a^2 * (1 + a)
c3 = -6a^2 - 3a - 3a^3
c4 = a^3 + 3a^2 + 3a + 1
ema1 = EMA(close, length)
ema2 = EMA(ema1, length)
ema3 = EMA(ema2, length)
ema4 = EMA(ema3, length)
ema5 = EMA(ema4, length)
ema6 = EMA(ema5, length)
T3 = c1 * ema6 + c2 * ema5 + c3 * ema4 + c4 * ema3
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-9
View File
@@ -12,15 +12,6 @@ def tema(close, length=None, talib=None, offset=None, **kwargs):
Sources:
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/triple-exponential-moving-average-tema/
Calculation:
Default Inputs:
length=10
EMA = Exponential Moving Average
ema1 = EMA(close, length)
ema2 = EMA(ema1, length)
ema3 = EMA(ema2, length)
TEMA = 3 * (ema1 - ema2) + ema3
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-8
View File
@@ -15,14 +15,6 @@ def trima(close, length=None, talib=None, offset=None, **kwargs):
tma = sma(sma(src, ceil(length / 2)), floor(length / 2) + 1) # Tradingview
trima = sma(sma(x, n), n) # Tradingview
Calculation:
Default Inputs:
length=10
SMA = Simple Moving Average
half_length = round(0.5 * (length + 1))
SMA1 = SMA(close, half_length)
TRIMA = SMA(SMA1, half_length)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-9
View File
@@ -17,15 +17,6 @@ def vidya(close, length=None, drift=None, offset=None, **kwargs):
https://www.tradingview.com/script/hdrf0fXV-Variable-Index-Dynamic-Average-VIDYA/
https://www.perfecttrendsystem.com/blog_mt4_2/en/vidya-indicator-for-mt4
Calculation:
Default Inputs:
length=10, adjust=False, sma=True
if sma:
sma_nth = close[0:length].sum() / length
close[:length - 1] = np.NaN
close.iloc[length - 1] = sma_nth
EMA = close.ewm(span=length, adjust=adjust).mean()
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 14
-5
View File
@@ -14,11 +14,6 @@ def vwap(high, low, close, volume, anchor=None, offset=None, **kwargs):
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/volume-weighted-average-price-vwap/
https://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:vwap_intraday
Calculation:
tp = typical_price = hlc3(high, low, close)
tpv = tp * volume
VWAP = tpv.cumsum() / volume.cumsum()
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-7
View File
@@ -11,13 +11,6 @@ def vwma(close, volume, length=None, offset=None, **kwargs):
Sources:
https://www.motivewave.com/studies/volume_weighted_moving_average.htm
Calculation:
Default Inputs:
length=10
SMA = Simple Moving Average
pv = close * volume
VWMA = SMA(pv, length) / SMA(volume, length)
Args:
close (pd.Series): Series of 'close's
volume (pd.Series): Series of 'volume's
-3
View File
@@ -12,9 +12,6 @@ def wcp(high, low, close, talib=None, offset=None, **kwargs):
Sources:
https://www.fmlabs.com/reference/default.htm?url=WeightedCloses.htm
Calculation:
WCP = (2 * close + high + low) / 4
Args:
high (pd.Series): Series of 'high's
low (pd.Series): Series of 'low's
-14
View File
@@ -13,20 +13,6 @@ def wma(close, length=None, asc=None, talib=None, offset=None, **kwargs):
Sources:
https://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average
Calculation:
Default Inputs:
length=10, asc=True
total_weight = 0.5 * length * (length + 1)
weights_ = [1, 2, ..., length + 1] # Ascending
weights = weights if asc else weights[::-1]
def linear_weights(w):
def _compute(x):
return (w * x).sum() / total_weight
return _compute
WMA = close.rolling(length)_.apply(linear_weights(weights), raw=True)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-9
View File
@@ -15,15 +15,6 @@ def zlma(close, length=None, mamode=None, offset=None, **kwargs):
Sources:
https://en.wikipedia.org/wiki/Zero_lag_exponential_moving_average
Calculation:
Default Inputs:
length=10, mamode=EMA
EMA = Exponential Moving Average
lag = int(0.5 * (length - 1))
SOURCE = 2 * close - close.shift(lag)
ZLMA = MA(kind=mamode, SOURCE, length)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-6
View File
@@ -15,12 +15,6 @@ def drawdown(close, offset=None, **kwargs) -> DataFrame:
Sources:
https://www.investopedia.com/terms/d/drawdown.asp
Calculation:
PEAKDD = close.cummax()
DD = PEAKDD - close
DD% = 1 - (close / PEAKDD)
DDlog = log(PEAKDD / close)
Args:
close (pd.Series): Series of 'close's.
offset (int): How many periods to offset the result. Default: 0
-6
View File
@@ -12,12 +12,6 @@ def log_return(close, length=None, cumulative=None, offset=None, **kwargs):
Sources:
https://stackoverflow.com/questions/31287552/logarithmic-returns-in-pandas-dataframe
Calculation:
Default Inputs:
length=1, cumulative=False
LOGRET = log( close.diff(periods=length) )
CUMLOGRET = LOGRET.cumsum() if cumulative
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 20
-6
View File
@@ -11,12 +11,6 @@ def percent_return(close, length=None, cumulative=None, offset=None, **kwargs):
Sources:
https://stackoverflow.com/questions/31287552/logarithmic-returns-in-pandas-dataframe
Calculation:
Default Inputs:
length=1, cumulative=False
PCTRET = close.pct_change(length)
CUMPCTRET = PCTRET.cumsum() if cumulative
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 20
-7
View File
@@ -13,13 +13,6 @@ def entropy(close, length=None, base=None, offset=None, **kwargs):
Sources:
https://en.wikipedia.org/wiki/Entropy_(information_theory)
Calculation:
Default Inputs:
length=10, base=2
P = close / SUM(close, length)
E = SUM(-P * npLog(P) / npLog(base), length)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 10
-5
View File
@@ -7,11 +7,6 @@ def kurtosis(close, length=None, offset=None, **kwargs):
Calculates the Kurtosis over a rolling period.
Calculation:
Default Inputs:
length=30
KURTOSIS = close.rolling(length).kurt()
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 30
-5
View File
@@ -8,11 +8,6 @@ def mad(close, length=None, offset=None, **kwargs):
Calculates the Mean Absolute Deviation over a rolling period.
Calculation:
Default Inputs:
length=30
mad = close.rolling(length).mad()
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 30
-5
View File
@@ -10,11 +10,6 @@ def median(close, length=None, offset=None, **kwargs):
Sources:
https://www.incrediblecharts.com/indicators/median_price.php
Calculation:
Default Inputs:
length=30
MEDIAN = close.rolling(length).median()
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 30
-5
View File
@@ -7,11 +7,6 @@ def quantile(close, length=None, q=None, offset=None, **kwargs):
Calculates the Quantile over a rolling period.
Calculation:
Default Inputs:
length=30, q=0.5
QUANTILE = close.rolling(length).quantile(q)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 30
-5
View File
@@ -7,11 +7,6 @@ def skew(close, length=None, offset=None, **kwargs):
Calculates the Skew over a rolling period.
Calculation:
Default Inputs:
length=30
SKEW = close.rolling(length).skew()
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 30
-6
View File
@@ -10,12 +10,6 @@ def stdev(close, length=None, ddof=None, talib=None, offset=None, **kwargs):
Calculates the Standard Deviation over a rolling period.
Calculation:
Default Inputs:
length=30
VAR = Variance
STDEV = variance(close, length).apply(np.sqrt)
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 30
-12
View File
@@ -17,18 +17,6 @@ def tos_stdevall(close, length=None, stds=None, ddof=None, offset=None, **kwargs
Sources:
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Statistical/StDevAll
Calculation:
Default Inputs:
length=None (All), stds=[1, 2, 3], ddof=1
LR = Linear Regression
STDEV = Standard Deviation
LR = LR(close, length)
STDEV = STDEV(close, length, ddof)
for level in stds:
LOWER = LR - level * STDEV
UPPER = LR + level * STDEV
Args:
close (pd.Series): Series of 'close's
length (int): Bars from current bar. Default: None
-5
View File
@@ -8,11 +8,6 @@ def variance(close, length=None, ddof=None, talib=None, offset=None, **kwargs):
Calculates the Variance over a rolling period.
Calculation:
Default Inputs:
length=30
VARIANCE = close.rolling(length).var()
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 30
-9
View File
@@ -9,15 +9,6 @@ def zscore(close, length=None, std=None, offset=None, **kwargs):
Calculates the Z Score over a rolling period.
Calculation:
Default Inputs:
length=30, std=1
SMA = Simple Moving Average
STDEV = Standard Deviation
std = std * STDEV(close, length)
mean = SMA(close, length)
ZSCORE = (close - mean) / std
Args:
close (pd.Series): Series of 'close's
length (int): It's period. Default: 30
+1 -51
View File
@@ -12,58 +12,8 @@ def adx(high, low, close, length=None, lensig=None, scalar=None, mamode=None, dr
the amount of movement in a single direction.
Sources:
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/average-directional-movement-adx/
TA Lib Correlation: >99%
Calculation:
DMI ADX TREND 2.0 by @TraderR0BERT, NETWORTHIE.COM
//Created by @TraderR0BERT, NETWORTHIE.COM, last updated 01/26/2016
//DMI Indicator
//Resolution input option for higher/lower time frames
study(title="DMI ADX TREND 2.0", shorttitle="ADX TREND 2.0")
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Length")
thold = input(20, title="Threshold")
threshold = thold
//Script for Indicator
dirmov(len) =>
up = change(high)
down = -change(low)
truerange = rma(tr, len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)
[plus, minus]
adx(dilen, adxlen) =>
[plus, minus] = dirmov(dilen)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)
[adx, plus, minus]
[sig, up, down] = adx(dilen, adxlen)
osob=input(40,title="Exhaustion Level for ADX, default = 40")
col = sig >= sig[1] ? green : sig <= sig[1] ? red : gray
//Plot Definitions Current Timeframe
p1 = plot(sig, color=col, linewidth = 3, title="ADX")
p2 = plot(sig, color=col, style=circles, linewidth=3, title="ADX")
p3 = plot(up, color=blue, linewidth = 3, title="+DI")
p4 = plot(up, color=blue, style=circles, linewidth=3, title="+DI")
p5 = plot(down, color=fuchsia, linewidth = 3, title="-DI")
p6 = plot(down, color=fuchsia, style=circles, linewidth=3, title="-DI")
h1 = plot(threshold, color=black, linewidth =3, title="Threshold")
trender = (sig >= up or sig >= down) ? 1 : 0
bgcolor(trender>0?black:gray, transp=85)
//Alert Function for ADX crossing Threshold
Up_Cross = crossover(up, threshold)
alertcondition(Up_Cross, title="DMI+ cross", message="DMI+ Crossing Threshold")
Down_Cross = crossover(down, threshold)
alertcondition(Down_Cross, title="DMI- cross", message="DMI- Crossing Threshold")
https://www.tradingtechnologies.com/help/x-study/technical-indicator-definitions/average-directional-movement-adx/
Args:
high (pd.Series): Series of 'high's

Some files were not shown because too many files have changed in this diff Show More