sinwma#

sinwma(close, length=None, offset=None, **kwargs)[source]#

Sine Weighted Moving Average (SWMA)

A weighted average using sine cycles. The middle term(s) of the average have the highest weight(s).

Source:

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 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: New feature generated.