PineCoders Squawk Box
Відкрити в Telegram
News & Tips on TradingView's Pine programming language
Показати більше3 493
Підписники
Немає даних24 години
+157 днів
+4730 день
Архів дописів
🌲 #newfeature
You can now use
timeframe.change("D") instead of ta.change(time("D")):
https://www.tradingview.com/pine-script-reference/v5/#fun_timeframe{dot}change💪 #tip
You can access the Pine Script™ Editor from anywhere, including on phones, by using this link:
https://www.tradingview.com/pine/
🌲 #newfeature
10 second charts are now available.
timeframe.period will return "10S" on them, as expected.🌲 #newfeature
The historical states of arrays and matrices can now be referenced with the `[]` operator. In the example below, we reference the historic state of a matrix 10 bars ago:
//@version=5
indicator("")
m = matrix.new<float>(1, 1, close)
float x = na
if bar_index > 10
x := matrix.get(m[10], 0, 0)
plot(x)🌲 #newfeature
`ta.change()` can now be called with a "bool" variable to detect state changes. You can now write:
//@version=5
indicator("", "", true)
bool upBar = close > open
bool directionChange = ta.change(upBar)
plotchar(directionChange, "directionChange", "•", location.top, size = size.tiny)🌲 #newfeature
To complement the recently introduced
chart.is_* variables, a new `chart.is_standard` variable detects when a standard chart type is used. Standard chart types are ones where the close is not synthetic, so bars, candles, hollow candles, line, area or baseline.🌲 #newfeature
A new `chart.bg_color
variable returns the color of the chart's background. Another one, chart.fg_color`, returns a color producing optimal contrast with that background.🌲 #newfeature
Six new parameters for `strategy.exit()` now allow you to generate different comments and alert messages depending on whether the order was triggered by a take profit, a stop loss or a trailing stop.
🌲 #newfeature
A new
syminfo.volumetype variable was added, which can help distinguish between base, quote and tick volumes on feeds for which the data vendor makes that information available. See it in use in the most recent "24-hour Volume" built-in indicator:
https://www.tradingview.com/blog/en/new-built-in-indicator-24-hour-volume-31718/🌲 #newfeature
A new `request.economic()` function provides scripts with access to economic data from different regions and sectors:
https://www.tradingview.com/blog/en/request-more-data-from-your-scripts-31944/
🌲 #newfeature
A new `request.security_lower_tf()` function makes it much easier to access information from intrabars, which are bars at a lower timeframe than the chart's. It returns an array containing one value per intrabar:
https://www.tradingview.com/blog/en/request-more-data-from-your-scripts-31944/
🌲 #newfeature
Premium accounts can now get more accurate strategy fills on their orders with the new Bar Magnifier feature. Keep in mind that more realistic fills do not necessarily produce more profits:
https://www.tradingview.com/blog/en/accurate-backtesting-with-bar-magnifier-31746/
🌲 #newfeature
The `risk_free_rate
parameter was added to `strategy(). It allows you to specify the reference rate of return used to calculate Sharpe and Sortino ratios.🌲 #newfeature
You can now extract the exchange or symbol part from any string in the "exchange:symbol" format using `syminfo.prefix(string)
and syminfo.ticker(string)`:
//@version=5
indicator("")
symbolInput = input.symbol("FX:USDCAD")
exchangeName = syminfo.prefix(symbolInput)
symbolName = syminfo.ticker(symbolInput)
ticker = ticker.new(exchangeName, symbolName, session.extended)
symbolClose = request.security(ticker, "1D", close)
plot(symbolClose)
if barstate.islastconfirmedhistory
label.new(bar_index, symbolClose, exchangeName + ":" + symbolName)🛠 #fix
math.round(na) used to return zero instead of na, contrary to how other built-ins behave. This has been fixed. math.round(na) now returns na. If needed, you can still reproduce the previous behavior with nz(math.round(x)).🌲 #newfeature
Variance, standard deviation and covariance built-in functions now have a
biased parameter. Its default true value continues to use estimates of the population. When false is used, estimates of the sample can now be used instead.🌲 #newfeature
Six new
chart.is_* built-in variables help us detect the chart type used.🌲 #newfeature
The branches of
if structures no longer need to return the same type when the if structure is not used to assign a value to a variable. This allows you to use if structures more liberally. Code like this will now compile:
//@version=5
indicator("", "", true)
var line e = na
if close > open
// This branch returns "void".
line.delete(e)
else
// This branch returns the "line" type.
e := line.new(bar_index - 10, high[10], bar_index, high)🔈 #news
You are welcome to join our new Q&A forum for Pine Script™ coders on Telegram: https://t.me/PineCodersQA
Note that the TradingView channel and this PineCoders Squawk Box are the only two other official TradingView outlets on Telegram.
Our new Telegram Q&A forum complements the two other Q&A forums where we already answer questions:
• The Stack Overflow [pine-script] tag
• The "Pine Script™ Q&A" public chat on TV
