Tradingview Pine scripts giving resolution error for line draw function

Viewed 4312
//@version=4

study(shorttitle="try", title="line", overlay=true, resolution="")

line.new(x1=bar_index[10], y1=close[10], x2=bar_index, y2=close)

I want to draw a simple line in trading view chart using pine scripts. I am getting resolution error. Am I missing anything?

Error: line 5: The 'resolution' argument is incompatible with functions that have side effects. Script 'crcheck' has been saved

2 Answers

Remove

, resolution=""

then it should work.

Wording is obscure because of space constraints, but it means you're using stuff that can't be calculated/rendered on other TFs. Doesn't mean it's impossible to code in Pine; you will most often be able to code it using security(); just means it can't be handled with the resolution method, whose purpose is to provide a simple way to provide MTF functionality for simple scripts. It does not deprecate security().

Related