如何在straution.entry()中添加第二个条件?

发布于 2025-01-25 20:21:22 字数 152 浏览 1 评论 0原文

我如何添加“策略条目”的条件,其中我只想考虑到200me以下的信号,

strategy.entry("Buy", strategy.long, 100.0, when = buySignal) 

这是当前的代码。如何添加条件?

How do i add a condition of "strategy entry" where i only want signals below the 200EMA to be taken into consideration

strategy.entry("Buy", strategy.long, 100.0, when = buySignal) 

This is the current code. How do i add the conditions to this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我一向站在原地 2025-02-01 20:21:22
  • 获取EMA首先
  • 将其添加到您已经存在的条件buysignal

这应该给您一个想法:

ema_length = 200
ema_source = close

ema = ta.ema(ema_source, ema_length)
is_ema_good = (close < ema)

if (is_ema_good and buySignal)
    strategy.entry("Buy", strategy.long, 100.0)
  • Get the ema first
  • Add this to your already existing condition buySignal

This should give you an idea:

ema_length = 200
ema_source = close

ema = ta.ema(ema_source, ema_length)
is_ema_good = (close < ema)

if (is_ema_good and buySignal)
    strategy.entry("Buy", strategy.long, 100.0)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文