Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to draw a rectangle in pinescript v4

I tried to create a rectangle using this code in pinescript v.4:

b = box.new(bar_index[100], highest(high,50), bar_index[10], lowest(low, 50), color.purple, 1, line.style_solid, extend.none, xloc.bar_index, color.new(color.purple, 90))
box.delete(b[1])

but getting error:

The 'resolution' argument is incompatible with functions that have side effects.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The resolution argument of the study() function is not compatible with the functions with side effects – drawings, alert() function calls etc.

In Pine Script v5, the resolution= parameter has been renamed timeframe= and this aspect is explicitly highlighted in the manual:

timeframe (const string) Adds multi-timeframe functionality to simple
scripts. When used, a "Timeframe" field will be added to the script’s
"Settings/Inputs" tab. … The parameter cannot be used with
scripts using Pine Script® drawings
.

https://www.tradingview.com/pine-script-reference/v5/#fun_indicator

Remove the resolution= and resolution_gaps= parameters from study() function call to be able to draw on the chart (boxes, lines, tables etc).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading