The resource loading... loading...

EMA appeals for help

Author: The Pig, Created: 2021-01-08 00:08:49, Updated: 2021-01-08 13:41:42

pine_ema(src, length) => alpha = 2 / (length + 1) sum = 0.0 sum := na(sum[1]) ? sma(src, length) : alpha * src + (1 - alpha) * nz(sum[1]) plot(pine_ema(close,15))

The EMA formula for TV is sum: = na ((sum[1])? sma ((src, length)): alpha * src + (1 - alpha) * nz ((sum[1]) I don't understand this passage, can anyone help me translate it into python, thank you.

The following notes:

  1. df[‘close’].ewm(span=110,adjust = False).mean()
  2. talib.EMA ((np.array ((close), timeperiod=110) The results of the tests are not consistent with TV (less than 50 is the same probability) and greater than 100 is not the same.

More

MAIKEOThis is a well-written ema function in JavaScript, and it's important to note that in the source array, the index and length parameters are calculated under different conditions.

MAIKEO function ema(src, length) { var arr = []; var sum = 0; var alpha = 2 / (length + 1) for(var i in src) { if( i<length-1 ) { arr[i] = null; sum += src[i]; } if( i==length-1 ) { arr[i] = (sum+src[i])/length; } else { arr[i] = alpha * src[i] + (1 - alpha) * arr[i-1] } } return arr; }

The grassThe ewm algorithm can be written as ewm = alpha*close+(1-alpha) *ewm

The Pig── is currently approximated by modifying exp=0.1── thank you。

The grassThe algorithms are not quite the same, there are subtle differences that can be ignored, such as how the first value should be taken using the iterative method, choose one yourself and go for it.

The PigIt's not like the results are the same as the EWMA. def EMA ((ps, period=5, exp=0.1)): This is a list of all the different ways ewma=pd.Series ((0.0,index=ps.index)) is credited in the database. ewma[period-1]=ps[:period].mean (((((((((((((((((((((((((((((((((((()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) For i in range (period, len (ps)): Ewma[i] = exp*ps[i]+(1-exp) *ewma[i-1] return ewma