我不知道Pine脚本,我有个问题要问你。就您的观点而言,是否可以在图表的右上角写一些信息?在详细情况下,我需要写ATR日报,和30%的ATR日报。我需要以前的AtrDaily关闭,如果我改变了图形上的时间框架。你能帮我吗?
提前感谢
发布于 2021-11-19 05:12:31
您可以使用table.new功能在表的右上角显示信息,并使用request.security()函数从不同的时间段(在您的示例中为每天)请求数据。
下面的代码将在图表的右上角打印每日ATR和每日ATR的30%。
//@version=5
indicator("My Script", overlay=true)
atr_daily = request.security(syminfo.tickerid, "D", ta.atr(14))
atr_daily_30 = atr_daily * 30 / 100
var testTable = table.new(position = position.top_right, columns = 1, rows = 2, bgcolor = color.yellow, border_width = 1)
if barstate.islast
table.cell(table_id = testTable, column = 0, row = 0, text = "ATR Daily: " + str.tostring(atr_daily))
table.cell(table_id = testTable, column = 0, row = 1, text = "ATR Daily (30%): " + str.tostring(atr_daily_30), bgcolor=color.teal)

https://stackoverflow.com/questions/70027424
复制相似问题