繁体   English   中英

如何使用 Pinescript 在 Tradingview 价格图表底部叠加形状或图标?

[英]How to overlay shapes or icon at the bottom of Tradingview price chart using Pinescript?

有什么方法可以使用 Pinescript 在 Tradingview 价格图表的底部添加图标或形状的叠加层,类似于股息、拆分、收益和新闻的事件图表设置的显示方式? 此外,能够将鼠标悬停在图标上以显示该事件的简要摘要。

在此处输入图像描述

您可以做的最接近的事情是将location参数与plotshape()plotchar()函数一起使用。 例如:

//@version=5
strategy("Template strategy", overlay=true, margin_long=100, margin_short=100)

longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (longCondition)
    strategy.entry("My Long Entry Id", strategy.long)

shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (shortCondition)
    strategy.entry("My Short Entry Id", strategy.short)


plotchar(longCondition, text = "Long", char='😀', location = location.bottom, size = size.small)
plotchar(shortCondition, text = "Short", char='🥺', location = location.bottom, size = size.small)

在此处输入图像描述

最接近的解决方案是不使用覆盖并将指标置于主图表的正下方,并使用label.new()label.set_tooltip()为不同的柱生成弹出文本。

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © thomastthai
// @version=5
    
indicator('Events', overlay=false, scale=scale.right, max_lines_count=500)
event1UnixTime = 1651687200000 
event1Label = label.new(x=event1UnixTime, xloc=xloc.bar_time, y=0, color=color.green, size=size.tiny)
label.set_tooltip(id=event1Label, tooltip="Event 1")
event2UnixTime = 1661687200000
event2Label = label.new(x=event2UnixTime, xloc=xloc.bar_time, y=0, color=color.red, size=size.tiny)
label.set_tooltip(id=event2Label, tooltip="Event 2")

在此处输入图像描述

暂无
暂无

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

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