簡體   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