PineCoders Squawk Box
3.87K subscribers
60 photos
166 links
News & Tips on TradingView's Pine programming language
Download Telegram
🌲 #newfeature
New label styles now allow you to position the label pointer in any direction when creating labels in Pine.
https://www.tradingview.com/pine-script-reference/v4/#fun_label%7Bdot%7Dnew
🌲 #newfeature
Get the value of a line at a specific bar index using the new line.getprice() function. Note that contrary to other line functions using bar indexing, a future bar can be referenced, using bar_index + 20 for example.
https://www.tradingview.com/blog/en/line-get_price-new-function-in-pine-script-18894/
🌲 #newfeature
When saving an indicator template, you can now associate a symbol to it.
🐞#bug
A recent problem has surfaced since Friday. It affects how script Inputs are handled. Checkboxes, dropdowns, and other Inputs sometimes do not behave as expected. A fix should come early in the week. Apologies for the inconvenience.
πŸžβš”οΈ #bugfix
The problem with script Inputs has been fixed.
πŸžβš”οΈ #bugfix
The problem with textalign= not working correctly has been fixed.
πŸžβš”οΈ #bugfix
The recent problem where scripts that used to run fine suddenly started timing out on the >20000ms message should now be fixed.
πŸžβš”οΈ #bugfix
There was a bug in the parser of published scripts descriptions that caused the # character in urls to be silently replaced by %, rendering links dysfunctional. The bug has been fixed.
🌲 #newfeature
The following functions now accept a series int argument for their length= parameter, which means the length can now vary with conditions that may change during the script's execution:
highest()
lowest()
highestbars()
lowestbars()

This is an example where we use a long length when price is above an MA, and a shorter length when price is below the MA:
//@version=4
study("Dynamic highest()", "", true)
ma = sma(close, 50)
var float hi = na
long = close > hi
hi := highest(high, high > ma ? 200 : 20)
plot(hi, "High", color.purple, 1, plot.style_circles)
plot(ma, "MA", color.silver)
plotchar(long, "long", "β–²", location.belowbar, color.lime, size = size.tiny)

https://www.tradingview.com/x/fW3oqnqm/
πŸ”ˆ #news
Script memory usage is now monitored. You may receive the following error on complex scripts:

Memory limits exceeded. The study allocates `x` bytes, max allowed is `y` bytes

See this Help Center document for more information, and please report occurrences in the Pine Script chat on TV.
πŸ”ˆ #news
Our selection of the best open-source indicators is now available in realtime, in a new "Editors' Picks" section of the Scripts stream. They will soon be integrated to TradingView's homepage.

We will continue to publish a separate, periodic roundup of the best Pine Utilities in Ideas from the PineCoders account on TV.
πŸ”ˆ #news
More on the "Memory limits exceeded" error message

The memory management logic that caused the error yesterday was turned off at the end of the day. It will soon be reactivated. While it will cause inconveniences, this step paves the way for significant improvements for most coders and users.

Previously, a few scripts consuming large amounts of memory often caused load imbalances that negatively impacted the execution time of many more "normal" scripts on the platform. Additionally, the advent of line and label drawings, and arrays very soon, put additional strain on resource consumption. Because there was previously no supervision of memory used by scripts, artificially low limits were imposed on features such as drawings.

Supervising memory usage will streamline resource use across all scripts on the platform, which will in turn allow the Pine team to increase the number of drawings allowed, provide a smoother environment for the coming arrays to operate in, and improve execution time for the majority of scripts on the platform. We believe these benefits largely offset the efforts that will be required for the few coders of resource-hungry scripts to optimize or adapt their scripts.

Note that the most frequent cause for the error involves the use of max_bars_back = 5000 in scripts, which is often unnecessary. See this Help Center page for more information on how to avoid the error, and this page to understand how to use max_bars_back correctly.
πŸ”ˆ #news
We have added a new link in the Unicode section of our Resources document. "Amp What" allows you to search Unicode characters by keyword:
https://www.pinecoders.com/resources/#unicode-characters
πŸ”ˆ #news
Pine cannot determine the referencing length of a series. Try using max_bars_back

Pine team's continued efforts to optimize memory use will in the next weeks lead to more scripts encountering the max_bars_back error message.

What's happening is that the default historical buffer size of 300 bars allocated to variables will gradually be decreased to 1 bar, as is currently the case with functions. You will thus need to use max_bars_back to explicitly allocate buffer size in some scripts that did not require it before.

A new Help Center page explains the details of what the historical buffer size is, how it works and how you can control it using max_bars_back in two different ways.
https://www.tradingview.com/?solution=43000587849
πŸ’ͺ #tip
Why do the OHLC built-ins sometimes return different values than the ones shown on the chart?
See the answer in our new FAQ entry.