用于检查最后交叉类型的代码

发布于 2025-01-27 23:04:30 字数 1081 浏览 1 评论 0原文

我希望我的代码检查最后一次发生的事件是Pitop还是Pibottom,然后根据最后一个事件的情况发出名为Bullish或看跌的信号。

    Pitop = crossover(MA111, MA350) ? security + (security/100 * 10) : na
    Pibottom = crossover(MA471, EMA150) ? security + (security/100 * 10) : na
  
    Bearish = crossover(MA111, EMA150) ? security + (security/100 * 10) : na and 
    Bullish = crossover(MA111, EMA150) ? security + (security/100 * 10) : na and 
    
    plotshape(Pitop, style=shape.labeldown,size=size.normal, text="Cycle Top", color=color.orange, textcolor=color.white, location=location.absolute)
    plotshape(Pibottom, style=shape.labeldown,size=size.normal, text="Cycle Bottom", color=color.red, textcolor=color.white, location=location.absolute)
    
    plotshape(Bearish,style=shape.labeldown,size=size.normal, text= "Bearish", color=color.teal,textcolor=color.white, location=location.absolute)
    plotshape(Bullish,style=shape.labeldown,size=size.normal, text= "Bullish", color=color.teal,textcolor=color.white, location=location.absolute)

如果上次发生的事件是pitop,我想要一个输出,以便我可以将其放在我的“和语句”的末尾,反之亦然。

I want my code to check if the last happened event is either Pitop or Pibottom then give out a signal either called bullish or bearish depending on the last event happened.

    Pitop = crossover(MA111, MA350) ? security + (security/100 * 10) : na
    Pibottom = crossover(MA471, EMA150) ? security + (security/100 * 10) : na
  
    Bearish = crossover(MA111, EMA150) ? security + (security/100 * 10) : na and 
    Bullish = crossover(MA111, EMA150) ? security + (security/100 * 10) : na and 
    
    plotshape(Pitop, style=shape.labeldown,size=size.normal, text="Cycle Top", color=color.orange, textcolor=color.white, location=location.absolute)
    plotshape(Pibottom, style=shape.labeldown,size=size.normal, text="Cycle Bottom", color=color.red, textcolor=color.white, location=location.absolute)
    
    plotshape(Bearish,style=shape.labeldown,size=size.normal, text= "Bearish", color=color.teal,textcolor=color.white, location=location.absolute)
    plotshape(Bullish,style=shape.labeldown,size=size.normal, text= "Bullish", color=color.teal,textcolor=color.white, location=location.absolute)

If last happened event is Pitop i want an output that says A so i can put it at the end of my "and" statement, and vice-versa.

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

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

发布评论

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

评论(1

面如桃花 2025-02-03 23:04:30

您可以使用ta.barss()来找出最后一个事件。最后一个事件的价值应该较低。

例如:

barssince_Pitop = ta.barssince(Pitop)
barssince_Pibottom = ta.barssince(Pibottom)

is_last_one_Pitop = barssince_Pitop < barssince_Pibottom

You can use ta.barssince() to figure out the last event. The last event should have a less value.

For example:

barssince_Pitop = ta.barssince(Pitop)
barssince_Pibottom = ta.barssince(Pibottom)

is_last_one_Pitop = barssince_Pitop < barssince_Pibottom
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文