'EMA calculation in python

I want to calculate ema in python. I searched on google a lot of functions are available. But I want to calculate ema with single value not serie values. I did it with pine script on tradingview here is my pinescript code:

dd = lowest (low, 4)//get lowest value in 4 series

yy = highest (high, 5)//get highest value in 5 series

diff = yy - dd

ortdiff = ema(ema(diff,3),3)

How can ı calculate ema of single values? Any library pr any function for calculate ema? Thanks

ema calculations on pinescripts:

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])

How can I calculate these functions on python?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source