如何修改TradingView交易面板生成的TP/SL指标栏颜色?
解决TradingView交易面板TP/SL颜色过淡的问题
核心结论
完全可以通过Pine Script修改,哪怕是零基础也能跟着操作,不需要复杂编程能力。
具体操作步骤
- 打开TradingView顶部菜单栏的「Pine Editor」,进入指标编辑器
- 新建空白脚本,替换成以下简化代码(专门用来重置TP/SL的显示样式):
//@version=5 indicator("自定义TP/SL颜色", overlay=true) // 获取交易面板生成的TP、SL水平值 tp_price = strategy.exit("Exit", limit=close) ? strategy.exit_limit : na sl_price = strategy.exit("Exit", stop=close) ? strategy.exit_stop : na // 绘制高对比度的水平线与标签 if not na(tp_price) line.new(bar_index, tp_price, bar_index+150, tp_price, color=#2ECC71, width=2) label.new(bar_index, tp_price, "TP", color=#2ECC71, textcolor=color.white, style=label.style_label_down) if not na(sl_price) line.new(bar_index, sl_price, bar_index+150, sl_price, color=#E74C3C, width=2) label.new(bar_index, sl_price, "SL", color=#E74C3C, textcolor=color.white, style=label.style_label_up)
- 代码里的
#2ECC71(TP深绿色)和#E74C3C(SL深红色)可以换成你喜欢的颜色,也可以直接用TradingView内置颜色,比如color.blue、color.orange - 点击编辑器右上角的「Add to Chart」,这个自定义指标会替代默认的淡色TP/SL显示
新手调整技巧
- 选对比强烈的配色:深色画布用亮系颜色,浅色画布用深系颜色
- 调整代码里的
width参数(比如改成3)让线条更粗,标签文字也会更醒目 - 如果不想关闭原交易面板的显示,可以直接隐藏原指标,只保留这个自定义指标
内容的提问来源于stack exchange,提问作者MaxReboot
相关产品推荐
相关产品推荐

