简体   繁体   English

如何在tradingview上添加图像水印松脚本

[英]How to add image watermark pine-script on tradingview

How do I add image/logo watermark on tradingview using pine-script?如何使用 pine-script 在交易视图上添加图像/徽标水印?

I am able to add text:我可以添加文字:

study("WaterMark + 4EMA [SilentKreator]", shorttitle="EMA + WM", overlay=true)
len1 = input(7, minval=1, title="EMA1")
len2 = input(25, minval=1, title="EMA2")
len3 = input(55, minval=1, title="EMA3")
len4 = input(200, minval=1, title="EMA4")
out1 = ema(close, len1)
out2 = ema(close, len2)
out3 = ema(close, len3)
out4 = ema(close, len4)
plot(out1, title="EMA1", color=color.yellow)
plot(out2, title="EMA2", color=color.red)
plot(out3, title="EMA3", color=color.green)
plot(out4, title="EMA4", color=color.blue)

Nombre = input("Nombre", title="WaterMark")
vcolor = input(color.new(color.white, 95), title="Color")

a = label.new(bar_index, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(a[1])

b = label.new(bar_index - 50, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(b[1])

c = label.new(bar_index - 150, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(c[1])

d = label.new(bar_index - 500, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(d[1])

e = label.new(bar_index - 1000, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(e[1])

f = label.new(bar_index - 1500, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(f[1])

g = label.new(bar_index - 2000, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(g[1])

h = label.new(bar_index - 4000, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(h[1])

i = label.new(bar_index - 6000, high, Nombre, 
  textcolor=vcolor,
  style=label.style_none, yloc=yloc.price, size=size.huge)
label.delete(i[1])

Is this officially supported or possible with pinescript? pinescript 是否正式支持或可能? I have been searching for hours but no one can do it except https://www.tradingview.com/script/ue1GHiNc-CryptoRADO-Watermarking-Tool-by-Cryptorhythms/我一直在寻找几个小时,但没有人能做到,除了https://www.tradingview.com/script/ue1GHiNc-CryptoRADO-Watermarking-Tool-by-Cryptorhythms/

Tradingview has published an open source example of a watermark . Tradingview 发布了一个水印的开源示例

// REUSING THIS CODE: You are welcome to reuse this code without permission, including in closed-source publications. Credits are appreciated. 

//@version=4
study("Watermark", "", true)

// Watermark
//  v1.0, 2021.05.27 19:06
// This code was written using the PineCoders Coding Conventions for Pine: http://www.pinecoders.com/coding_conventions/

string  i_text1     = input("I💙TradingView", "Text 1", inline = "11")
string  i_text2     = input("I💚Pine", "Text 2", inline = "11", tooltip = "Clear 'Text 2' to prevent animation.")
string  i_tableYpos = input("bottom", "Position", inline = "12", options = ["top", "middle", "bottom"])
string  i_tableXpos = input("left", "", inline = "12", options = ["left", "center", "right"])
int     i_height    = input(3, "Height", minval = 1, maxval = 100, inline = "13")
int     i_width     = input(10, "Width",  minval = 1, maxval = 100, inline = "13", tooltip = "1-100")
color   i_c_text    = input(color.new(color.white, 30), "Text", inline = "14")
string  i_textSize  = input("normal", "Size", inline = "14", options = ["tiny", "small", "normal", "large", "huge", "auto"])
color   i_c_bg      = input(color.new(color.blue, 50), "Background")

// We use `var` to only initialize the table on the first bar.
var table watermark = table.new(i_tableYpos + "_" + i_tableXpos, 1, 1)

// We only populate the table on the last bar; it's more efficient.
if barstate.islast
    // This `varip` variable will preserve its value across realtime updates.
    varip bool _changeText = true
    // Toggle this value on each update.
    _changeText := not _changeText
    // If there's a "Text 2" string in inputs and it's time to flip, change the text.
    string _txt = str.length(i_text2) != 0 and _changeText ? i_text2 : i_text1
    // Populate our table cell.
    table.cell(watermark, 0, 0, _txt, i_width, i_height, i_c_text, text_size = i_textSize, bgcolor = i_c_bg)

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

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