“时间框架”参数与具有副作用的函数不兼容 – 这是什么意思?

huangapple go评论87阅读模式
英文:

"The 'timeframe' argument is incompatible with functions that have side effects" – what does it mean?

问题

我将我的富VWAP指标移动到一个面板上,以避免在图表上弄得太乱,但在这个面板中,我显然看不到价格(收盘价)。因此,我决定使用box()来绘制它。

var box PriceRectangular = na
if(na(PriceRectangular))
    PriceRectangular := box.new(left=bar_index, top=close, right=bar_index, bottom=close, border_color=#8888880a, border_width=2, bgcolor=#00000000, extend=extend.right)
    box.set_left(PriceRectangular, bar_index)
    box.set_border_width(PriceRectangular, 2)
    box.set_top(PriceRectangular, close)
    box.set_right(PriceRectangular, bar_index)
    box.set_bottom(PriceRectangular, close)
    box.set_border_color(PriceRectangular, #8888880a)
    box.set_bgcolor(PriceRectangular, #00000000)
    box.set_extend(PriceRectangular, extend.right)
else
    box.set_left(PriceRectangular, bar_index)
    box.set_border_width(PriceRectangular, 2)
    box.set_top(PriceRectangular, close)
    box.set_right(PriceRectangular, bar_index)
    box.set_bottom(PriceRectangular, close)
    box.set_border_color(PriceRectangular, #8888880a)
    box.set_bgcolor(PriceRectangular, #00000000)
    box.set_extend(PriceRectangular, extend.right)

代码本身在其他地方(在图表上)可以正常工作,但在这里,它出现了上面的错误消息。是否有任何解决方法?

英文:

I moved my rich VWAP indicator out to a Pane to avoid making too big mess on the chart but here in the Pane, I obviously don't see the price (close) there. So I decided to draw it using a box().

var box PriceRectangular = na
if(na(PriceRectangular))
	PriceRectangular := box.new(left=bar_index, top=close, right=bar_index, bottom=close, border_color=#8888880a, border_width=2, bgcolor=#00000000, extend=extend.right)
	box.set_left(PriceRectangular, bar_index)
	box.set_border_width(PriceRectangular, 2)
	box.set_top(PriceRectangular, close)
	box.set_right(PriceRectangular, bar_index)
	box.set_bottom(PriceRectangular, close)
	box.set_border_color(PriceRectangular, #8888880a)
	box.set_bgcolor(PriceRectangular, #00000000)
	box.set_extend(PriceRectangular, extend.right)
else
	box.set_left(PriceRectangular, bar_index)
	box.set_border_width(PriceRectangular, 2)
	box.set_top(PriceRectangular, close)
	box.set_right(PriceRectangular, bar_index)
	box.set_bottom(PriceRectangular, close)
	box.set_border_color(PriceRectangular, #8888880a)
	box.set_bgcolor(PriceRectangular, #00000000)
	box.set_extend(PriceRectangular, extend.right)

The code itself works elsewhere (on-chart) but here, it fails with the error message above. Is there any workaround?

答案1

得分: 1

你将主要遇到这个问题,如果你正在使用任何绘图对象。这意味着TradingView无法自动对你的代码进行多时间框架分析。

要消除这个错误,你需要从你的indicator()调用中删除语句timeframe=""timeframe_gaps=true

如果你确实需要进行多时间框架分析,你应该自己使用security()函数来实现。

英文:

You will mostly have this issue if you are using any drawing objects. It means that, Tradingview is unable to do a multitimeframe anlaysis of your code automatically.

To get rid of this error, you need to remove the statements timeframe="", timeframe_gaps=true from your indicator() call.

If you really need multi timeframe analysis, you should do that yourself by using security() function.

huangapple
  • 本文由 发表于 2023年3月7日 23:11:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/75663755.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定