croos时添加情节

Add plot when croos

我想在两条线交叉的时候加一个圆

study(title="Williams %R", shorttitle="The Willy")

// Williams %R
length = input(defval=21, minval=1)
upper = highest(length)
lower = lowest(length)

output = 100 * (close - upper) / (upper - lower)
ema = ema(output, input(defval=13, title="EMA"))

// Plot   
h1 = hline(-20, title="Upper Band")
h2 = hline(-80, title="Lower Band")
fill(h1, h2, title="Background")

plot(output, title="%R", color=yellow, linewidth=2)
plot(ema, title="EMA", color=aqua, linewidth=2)
plot(ta.cross(output, ema) ? signal : na, color= #00ff0a, style = plot.style_circles, linewidth = 2)

我试过这最后一行,但没有用。

预先感谢您的帮助。

您的代码是 v3v4v5 的混合体。你应该先解决这个问题。

之后,你正在寻找ta.cross()看是否有十字和plotshape()功能来显示圆圈。

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vitruvius

//@version=5
indicator(title="Williams %R", shorttitle="The Willy")

// Williams %R
length = input.int(defval=21, minval=1)
ema_len = input(defval=13, title="EMA")
upper = ta.highest(length)
lower = ta.lowest(length)

output = 100 * (close - upper) / (upper - lower)
_ema = ta.ema(output, ema_len)
is_cross = ta.cross(output, _ema)

// Plot   
h1 = hline(-20, title="Upper Band")
h2 = hline(-80, title="Lower Band")

plot(output, title="%R", color=color.yellow, linewidth=2)
plot(_ema, title="EMA", color=color.aqua, linewidth=2)
plotshape(is_cross ? _ema : na, "Cross", shape.circle, location.absolute, color=#00ff0a)