用于检查最后交叉类型的代码
我希望我的代码检查最后一次发生的事件是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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
ta.barss()
来找出最后一个事件。最后一个事件的价值应该较低。例如:
You can use
ta.barssince()
to figure out the last event. The last event should have a less value.For example: