首页 > 解决方案 > 用文本替换带有 plotshape 的箭头

问题描述

我有这个脚本,当移动平均线交叉时添加一个箭头,但想显示标签向上/标签向下。

    study(title="MA 5/10 Strategy", shorttitle="MA Strategy 5/10", overlay=true)
exponential = input(true, title="Exponential MA")

src = close

ma5 = exponential ? ema(src, 5) : sma(src, 5)
ma10 = exponential ? ema(src, 10) : sma(src, 10)

buy_cond = cross(ma5, ma10) and ma5 > ma10
sell_cond = cross(ma5, ma10) and ma5 < ma10

plotarrow(buy_cond ? 1 : 0, colordown=lime, maxheight=25, minheight=15)
plotarrow(sell_cond ? -1 : 0, colorup=red, maxheight=25, minheight=15)

plot( ma5, color=green, style=line, title="5", linewidth=1)
plot( ma10, color=red, style=line, title="10", linewidth=1)

alertcondition(buy_cond, title = "Go Long", message = "Go Long")
alertcondition(sell_cond, title = "Go Short", message = "Go Short")

标签: pine-script

解决方案


推荐阅读