Я хочу настроить оповещение в торговом представлении, когда свечи поглощения касаются одной линии скользящей средней. Я создал часть. Но не в состоянии определить касания поглощающих свечей и скользящей средней.
Вот мой код:
`//@version=5
indicator(title = "Indicator", shorttitle = "In", overlay=true, timeframe = "", timeframe_gaps=true)
len = input.int(21, minval=1, title = "Length")
src = input(close, title = "Source")
smma = 0.0
smma := na(smma[1]) ? ta.sma(src, len) : (smma[1] * (len - 1) + src) / len
openBarPrevious = open[1]
closeBarPrevious = close[1]
openBarCurrent = open
closeBarCurrent = close
green = color.green
red = color.red
//If current bar open is less than equal to the previous bar close AND current bar open is less than previous bar open AND current bar close is greater than previous bar open THEN True
bullishEngulfing = (openBarCurrent <= closeBarPrevious) and (openBarCurrent < openBarPrevious) and (closeBarCurrent > openBarPrevious)
//If current bar open is greater than equal to previous bar close AND current bar open is greater than previous bar open AND current bar close is less than previous bar open THEN True
bearishEngulfing = (openBarCurrent >= closeBarPrevious) and (openBarCurrent > openBarPrevious) and (closeBarCurrent < openBarPrevious)
//bullishEngulfing/bearishEngulfing return a value of 1 or 0; if 1 then plot on chart, if 0 then don't plot
plotshape(bullishEngulfing, style = shape.triangleup, location = location.belowbar, color = green, size = size.tiny)
plotshape(bearishEngulfing, style = shape.triangledown , location = location.abovebar, color = red, size = size.tiny)
plot(smma, color=#ffffff)`
Я хочу установить оповещение, если свечи поглощения касаются скользящей средней. Пожалуйста помоги мне с этим.
Если вы хотите обнаружить касание и не интересует, где цена закрывается, вам следует использовать фитили. Просто проверьте, пересекли ли high
или low
свечи линию MA.
is_bullish_high_touch = bullishEngulfing and ta.cross(high, smma)
is_bearish_low_touch = bearishEngulfing and ta.cross(low, smma)
Конечно, это возможно. Что вы пробовали? Вы можете задать новый вопрос для этого.
Не могли бы вы проверить это? stackoverflow.com/questions/75142796/…
Спасибо, это работает. Но мне было интересно, могу ли я каким-то образом вызвать оповещение, когда цена (максимум или минимум) касается MA. Кроме того, можно ли проверить, находится ли цена ниже или выше скользящей средней.