0

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?

Farshid616
  • 1,404
  • 1
  • 14
  • 26
2W-14
  • 11
  • 3

1 Answers1

1

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()
Have a nice day
  • 1,007
  • 5
  • 11
samlordon
  • 11
  • 1