首页 > 解决方案 > 将 EMA 添加到警报查询

问题描述

对于比我有更多知识的人来说,这是一个快速解决方案。我已对 pinbar 发出警报,但我只希望它们显示它们是否高于 EMA20 线。

//Alert

aboveema = abs(close-open) > ema(close,20)

pinbarup = upshadow>body?prevc>pbody?(close[1]>open[1]?(body[1]>body?(high>high[1]?(upshadow>0.5*body?(upshadow>2*downshadow?1:0):0):0):0):0):0:0 and aboveema

alertcondition(pinbarup, title="PinbarUp", message="PinbarUp")

标签: alertpine-scripttrend

解决方案


您的代码应该已经这样做了,因为您在aboveema条件结束时pinbarup有条件。此版本在功能上是等效的,但用于and加入您的条件,因此消除了对三元组的需要:

pinbarup = upshadow > body and prevc > pbody and close[1] > open[1] and body[1] > body and high > high[1] and upshadow > 0.5 * body and upshadow > 2 * downshadow and aboveema

推荐阅读