You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TradingView PineScript:移除多余颜色设置框及Input标签

解决PineScript移除Input标签后出现额外颜色设置框的问题

问题原因

删除所有input.*()函数后,TradingView会自动为每个plot()生成默认颜色设置项(即你看到的Color 0、Color1等),因为脚本里的plot()未配置display参数来隐藏这些默认样式选项。

解决步骤

要彻底移除设置面板的所有输入项(包括自动生成的颜色框),需对indicator()和所有plot()函数做以下修改:

  1. 给indicator()添加display=display.data_window参数,隐藏设置面板的标签;
  2. 给每个plot()添加display=display.none参数,禁止生成默认颜色设置项。

修改后的完整脚本

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

//@version=5
indicator("ADR", overlay=true, display=display.data_window)  // 添加display参数隐藏设置面板标签

//ADR side of script below

text_ADR1_high = 'ADR Upper'
text_ADR2_high = 'ADR Upper'

text_ADR1_low = 'ADR Lower'
text_ADR2_low = 'ADR Lower'

lime = #00FF00 //ADR2 Low
limes = #00FF00 //ADR1 Low
red = #FF4000 //ADR1 High
reds = #FF4000 //ADR2 High

//***Start of Inputs

labels_enabled = true

color_ADR1_high = red
color_ADR2_high = reds

color_ADR1_low = lime
color_ADR2_low = limes

adrUppercolorfill = red
adrlowercolorfill = lime
   
//***End of Inputs

//***Start of local functions definiton***

adr_1 = 10
adr_2 = 5

draw_line(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) =>
    dline = line.new(x1=_x1, y1=_y1, x2=_x2, y2=_y2, xloc=_xloc, extend=_extend, color=_color, style=_style, width=_width)
    line.delete(dline[1])
    
draw_label(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) =>
    dlabel = label.new(x=_x, y=_y, text=_text, xloc=_xloc, yloc=_yloc, color=_color, style=_style, textcolor=_textcolor, size=_size, textalign=_textalign, tooltip=_tooltip)
    label.delete(dlabel[1])

//If security is futures - replace the ticker with continuous contract
tickerid_func() =>
    tickerid = syminfo.tickerid
    if syminfo.type == 'futures'
        tickerid := syminfo.root + '1!'

//Function to calculate ADR levels
//Parameters:
//  * lengthInput - ADR period
//  * hi_low - true-->High, else-->Low 
adr_func(lengthInput,hi_low) =>
    float result = 0
    float adr = 0
    open_ = request.security(tickerid_func(), "D", open, barmerge.gaps_off, barmerge.lookahead_on)
    adr_High = request.security(tickerid_func(), "D", ta.sma(high[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on)
    adr_Low = request.security(tickerid_func(), "D", ta.sma(low[1], lengthInput), barmerge.gaps_off, barmerge.lookahead_on)
    adr := (adr_High - adr_Low)
    
    if hi_low//High
        result := adr/2 + open_
    else    //Low
        result := open_ - adr/2    

//Workaround to disable color management on the standard tab Style for plots
//Custom inputs for colors should be used instead
transp_func() =>
    transp_0 = 0

//***End of local functions definiton***

//***Start of getting data

start_time = request.security(tickerid_func(), "D", time_close[1],barmerge.gaps_off,barmerge.lookahead_on)
open__ = request.security(tickerid_func(), "D", open, barmerge.gaps_off, barmerge.lookahead_on)

start_time1 = request.security(tickerid_func(), "W", time_close[1],barmerge.gaps_off,barmerge.lookahead_on)

adr1_high = adr_func(adr_1,true)
adr1_low = adr_func(adr_1,false)
adr2_high = adr_func(adr_2,true)
adr2_low = adr_func(adr_2,false)

//***End of getting data

float _adr1_high = na
float _adr1_low = na
float _adr2_high = na
float _adr2_low = na
float _open = na

//*********************

//***Start of plotting*

//Decide if we can show the chart:
//Daily levels should be visible on intraday chart only

var show_chart = false

if timeframe.isintraday
    show_chart := true
    
//Plot all days
if show_chart
    _adr1_high := adr1_high
    _adr1_low  := adr1_low
    _adr2_high := adr2_high
    _adr2_low  := adr2_low
    _open      := open__

// 给每个plot添加display=display.none,隐藏默认颜色设置项
ADR1_high = plot(_adr1_high, title=text_ADR1_high, color=ta.change(_adr1_high) ? na : color_ADR1_high, linewidth=1, display=display.none)
ADR2_high = plot(_adr2_high, title=text_ADR2_high, color=ta.change(_adr2_high) ? na : color_ADR2_high, linewidth=1, display=display.none)
ADR1_low = plot(_adr1_low, title=text_ADR1_low, color=ta.change(_adr1_low) ? na : color_ADR1_low, linewidth=1, display=display.none)
ADR2_low = plot(_adr2_low, title=text_ADR2_low, color=ta.change(_adr2_low) ? na : color_ADR2_low, linewidth=1, display=display.none)
fill(plot1 = ADR1_high, plot2 = ADR2_high, color = ta.change(_adr1_high) ? na : color.new(adrUppercolorfill, 80))
fill(plot1 = ADR1_low, plot2 = ADR2_low, color = ta.change(_adr1_low) ? na : color.new(adrlowercolorfill, 80))

//***Start of Labels***

label_ADR1_high = ''
label_ADR2_high = ''

label_ADR1_low = ''
label_ADR2_low = ''

if labels_enabled == true
    label_ADR1_high := str.tostring(math.round_to_mintick(adr1_high))
    label_ADR2_high := str.tostring(math.round_to_mintick(adr2_high))
    
    label_ADR1_low  := str.tostring(math.round_to_mintick(adr1_low))
    label_ADR2_low  := str.tostring(math.round_to_mintick(adr2_low))
        
string_ADR1_high = ' (' + label_ADR1_high + ')'
string_ADR2_high = ' (' + label_ADR2_high + ')'

string_ADR1_low = ' (' + label_ADR1_low + ')'
string_ADR2_low = ' (' + label_ADR2_low + ')'

//Labels
if show_chart and labels_enabled == true
    draw_label(bar_index + 1, adr1_high, text_ADR1_high + string_ADR1_high, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR1_high,transp_func()), size.normal, text.align_left, '') 
    draw_label(bar_index + 1, adr2_high, text_ADR2_high + string_ADR2_high, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR2_high,transp_func()), size.normal, text.align_left, '')
  
    draw_label(bar_index + 1, adr1_low,  text_ADR1_low + string_ADR1_low, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR1_low,transp_func()), size.normal, text.align_left, '')   
    draw_label(bar_index + 1, adr2_low,  text_ADR2_low + string_ADR2_low, xloc.bar_index, yloc.price, color.new(color.white, 100), label.style_label_left, color.new(color_ADR2_low,transp_func()), size.normal, text.align_left, '')  

///////////////////////////////////////////////////////////////////////////////////////////

关键修改说明

  • indicator("ADR", overlay=true, display=display.data_window):display.data_window参数让指标仅显示在数据窗口,直接隐藏设置面板的标签;
  • plot(..., display=display.none):该参数会阻止TradingView为对应plot生成任何默认样式设置项,包括自动出现的颜色选择框。

内容的提问来源于stack exchange,提问作者cryptoweeknd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 01:15:39