简体   繁体   中英

NumPy version of “Exponential weighted moving average”, equivalent to TradingView RMA

How do I get exponentially weighted moving average with alpha = 1 / length equivalent to RMA function in TradingView RMA ?

I tried all functions mentioned in NumPy version of "Exponential weighted moving average", equivalent to pandas.ewm().mean() however can't match results to TradingView.

array
src = np.array([4086.29, 4310.01, 4509.08, 4130.37, 3699.99, 3660.02, 4378.48, 4640.0, 5709.99, 5950.02])

with period = 3

Should give results:

array([          nan,           nan, 4301.79333333, 4244.65222222,
       4063.09814815, 3928.73876543, 4078.65251029, 4265.76834019,
       4747.17556013, 5148.12370675])

Any ideas how to achieve it?

I managed to get it matched with the following parameters using pandas:

window = 14
df['mean'] = df['close'].ewm(alpha = 1/window, min_periods = window, adjust = False).mean()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM