PineScript 奇怪的行为正在创建 Table。使用 IF barstate.islast 创建 table.cells 时 Table 显示为点
PineScript strange behaviour creating Table. Table is displayed as dot when using IF barstate.islast to create table.cells
您好,我隔离了导致这种奇怪行为的代码。这是由可变价格引起的。有办法吗?
//@version=5
strategy("My script",overlay=true)
testTable = table.new(position = position.top_right, columns = 2, rows = 1, border_width = 1,border_color = color.white,frame_width = 1,frame_color = color.white)
if barstate.islast
table.cell(table_id = testTable, column = 0, row = 0, text = "Text 1",text_size = size.large,text_color = color.white)
table.cell(table_id = testTable, column = 1, row = 0, text = "Text 2",text_size = size.large,text_color = color.white)
price = request.security(syminfo.tickerid,"D", high[1], lookahead=barmerge.lookahead_on)
crossover = (close > price)
strategy.entry("enter long", strategy.long, 1, when = crossover)
是barstate.islast
造成的。您在此本地块内创建了 table 个单元格。当未创建单元格时,仅使用 table.new()
函数初始化 table 变量,将只有一个点图(table 边框之间没有间距)。
因此 barstate.islast
对于非即时交易品种是正确的,或者在当前最后一个柱关闭后(策略在每个柱关闭时计算)对于 RT 柱。
根据您的情况使用任何其他 barstates
。例如。 barstate.islastconfirmedhistory
将在柱是最后一个历史柱时绘制单元格。 barstate.isrealtime
将实时重绘单元格。
//@version=5
strategy("My script",overlay=true)
testTable = table.new(position = position.top_right, columns = 2, rows = 1, border_width = 1,border_color = color.white,frame_width = 1,frame_color = color.white)
if barstate.islastconfirmedhistory or barstate.isrealtime
table.cell(table_id = testTable, column = 0, row = 0, text = "Text 1",text_size = size.large,text_color = color.white)
table.cell(table_id = testTable, column = 1, row = 0, text = "Text 2",text_size = size.large,text_color = color.white)
price = request.security(syminfo.tickerid,"D", high[1], lookahead=barmerge.lookahead_on)
crossover = (close > price)
strategy.entry("enter long", strategy.long, 1, when = crossover)
您好,我隔离了导致这种奇怪行为的代码。这是由可变价格引起的。有办法吗?
//@version=5
strategy("My script",overlay=true)
testTable = table.new(position = position.top_right, columns = 2, rows = 1, border_width = 1,border_color = color.white,frame_width = 1,frame_color = color.white)
if barstate.islast
table.cell(table_id = testTable, column = 0, row = 0, text = "Text 1",text_size = size.large,text_color = color.white)
table.cell(table_id = testTable, column = 1, row = 0, text = "Text 2",text_size = size.large,text_color = color.white)
price = request.security(syminfo.tickerid,"D", high[1], lookahead=barmerge.lookahead_on)
crossover = (close > price)
strategy.entry("enter long", strategy.long, 1, when = crossover)
是barstate.islast
造成的。您在此本地块内创建了 table 个单元格。当未创建单元格时,仅使用 table.new()
函数初始化 table 变量,将只有一个点图(table 边框之间没有间距)。
因此 barstate.islast
对于非即时交易品种是正确的,或者在当前最后一个柱关闭后(策略在每个柱关闭时计算)对于 RT 柱。
根据您的情况使用任何其他 barstates
。例如。 barstate.islastconfirmedhistory
将在柱是最后一个历史柱时绘制单元格。 barstate.isrealtime
将实时重绘单元格。
//@version=5
strategy("My script",overlay=true)
testTable = table.new(position = position.top_right, columns = 2, rows = 1, border_width = 1,border_color = color.white,frame_width = 1,frame_color = color.white)
if barstate.islastconfirmedhistory or barstate.isrealtime
table.cell(table_id = testTable, column = 0, row = 0, text = "Text 1",text_size = size.large,text_color = color.white)
table.cell(table_id = testTable, column = 1, row = 0, text = "Text 2",text_size = size.large,text_color = color.white)
price = request.security(syminfo.tickerid,"D", high[1], lookahead=barmerge.lookahead_on)
crossover = (close > price)
strategy.entry("enter long", strategy.long, 1, when = crossover)