Python中的EMA计算

发布于 2025-01-21 22:11:39 字数 587 浏览 2 评论 0原文

我想在Python中计算EMA。我在Google上搜索了很多功能。但是我想用单个值而不是意甲值来计算EMA。我用Pine脚本在TradingView上做到了这是我的Pinescript代码:

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)

ı如何计算单个值的EMA?有任何库PR用于计算EMA的任何功能吗? 感谢

Pinescripts上的EMA计算:

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

如何在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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文