繁体   English   中英

Pinescript:如何在 Bar 下方/上方设置一个 plotshape label 一段距离?

[英]Pinescript: How to set a plotshape label below/above the Bar with some distance?

如何在条形下方/上方设置一定距离的绘图形状 label? 就像下面的截图一样。 在此处输入图像描述

//@version=4
study("My Script", overlay = true)

ema1 = ema(close, 13)
ema2 = ema(close, 50)

condition = crossover(ema1, ema2)

plot(ema1)
plot(ema2)

// 
atr_dist = atr(14) //atr distance
perc_dist = input(2.0, "Distance in %:") //% distance

if condition
    // label.new(bar_index, high + atr_dist, "Above", style=label.style_label_down, color = color.green)
    label.new(bar_index, high + high *perc_dist /100, "Above", style=label.style_label_down, color = color.green) //or use % as distance
    // label.new(bar_index, high - atr_dist, "Below", style=label.style_label_up, color = color.red)
    label.new(bar_index, low - low *perc_dist /100, "Below", style=label.style_label_up, color = color.red) //or use % as distance

在此处输入图像描述

你可以使用\n

例子:

plotchar(dcc, title="Dark cloud cover", char="☁", location=location.top, color=color.orange, text=".\n.\n.\Dcc")

plotshape(test, title="test",style=shape.circle, location=location.belowbar, color=color.red, text="test\n\n")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM