🌲 #newfeature
Dear quants, please welcome Pine Script™ matrices!
https://www.tradingview.com/blog/en/matrices-come-to-pine-script-30693/
Dear quants, please welcome Pine Script™ matrices!
https://www.tradingview.com/blog/en/matrices-come-to-pine-script-30693/
TradingView Blog
Matrices come to Pine Script®
Latest Updates to Track All Markets
🔥21❤5🥰3👍1
🌲 #newfeature
You can now use placeholders of the form
You can now use placeholders of the form
{{strategy.*}}
in the string used with the alert_message
parameter of strategy.*()
functions. This makes realtime information available in alert messages generated from scripts, just as can be done when using the placeholders from the "Create Alert" dialog box's "Message" field://@version=5
strategy("My strategy", overlay=true, margin_long=100, margin_short=100)
alertString = '{{strategy.order.action}} {{strategy.position_size}} {{ticker}} \nMarket position was {{strategy.prev_market_position}} and is now {{strategy.market_position}}'
longCondition = ta.crossover(ta.sma(close, 14), ta.sma(close, 28))
if (longCondition)
strategy.entry("My Long Entry Id", strategy.long, alert_message = alertString)
shortCondition = ta.crossunder(ta.sma(close, 14), ta.sma(close, 28))
if (shortCondition)
strategy.entry("My Short Entry Id", strategy.short, alert_message = alertString)
❤29👍6
🌲 #newfeature
Improvements to
Improvements to
request.security()
were rolled out. Its expression
parameter now supports arguments of "string" type, and "int[]/float[]/bool[]/color[]/string[]" arrays, including in tuples://@version=5
indicator("")
bool barUp = close > open
color barColor = barUp ? color.green : color.red
string barDesc = barUp ? "Bar is UP" : "Bar is DOWN"
bool[] arrayBool = array.from(barUp, barUp[1])
color[] arrayColor = array.from(barColor, barColor[1])
string[] arrayString = array.from(barDesc, barDesc[1])
float[] arrayFloat = array.from(close, open)
sBool = request.security(syminfo.tickerid, "1M", close > open)
sColor = request.security(syminfo.tickerid, "1M", barColor)
sString = request.security(syminfo.tickerid, "1M", timeframe.period)
sArrayBool = request.security(syminfo.tickerid, "1M", arrayBool)
sArrayColor = request.security(syminfo.tickerid, "1M", arrayColor)
sArrayString = request.security(syminfo.tickerid, "1M", arrayString)
sArrayFloat = request.security(syminfo.tickerid, "1M", arrayFloat)
[tArrayBool, tArrayColor, tArrayFloat] = request.security(syminfo.tickerid, "1M", [arrayBool, arrayColor, arrayFloat])
if barstate.islast
label.new(bar_index, 0,
sString + "\n" +
str.tostring(sBool) + "\n" +
str.tostring(sArrayBool) + "\n" +
str.tostring(sArrayString) + "\n" +
str.tostring(sArrayFloat) + "\n",
color = array.get(tArrayColor, 0))
👍34🔥7❤6
🔈 #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
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
Telegram
PineCoders Pine Script® Q&A
Q&A for TradingView's Pine programming language
For a complete list of all PineCoders & TradingView outlets, please see:
t.me/PineCodersOfficial
For a complete list of all PineCoders & TradingView outlets, please see:
t.me/PineCodersOfficial
👏4❤2👍1🔥1💩1
PineCoders Squawk Box
🌲 #newfeature Improvements to request.security() were rolled out. Its expression parameter now supports arguments of "string" type, and "int[]/float[]/bool[]/color[]/string[]" arrays, including in tuples: //@version=5 indicator("") bool barUp =…
🌲 #newfeature
The branches of
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)
❤17👍13🔥2👏2
🌲 #newfeature
Variance, standard deviation and covariance built-in functions now have a
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.👍15🤔3😁1
🛠 #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))
.👍11
🌲 #newfeature
You can now extract the exchange or symbol part from any string in the "exchange:symbol" format using syminfo.prefix(string)
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)
TradingView
Pine Script Language Reference Manual
👍25❤1
🌲 #newfeature
The
https://www.tradingview.com/pine-script-reference/v5/#fun_strategy
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:https://www.tradingview.com/pine-script-reference/v5/#fun_strategy
👍10👏2🔥1
🌲 #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/
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/
TradingView Blog
Backtest more accurately with the Bar Magnifier
Latest Updates to Track All Markets
🔥11👍2👏2
🌲 #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/
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/
🔥18👍8
🌲 #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/
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/
👍4🔥4❤1
🌲 #newfeature
A new
https://www.tradingview.com/blog/en/new-built-in-indicator-24-hour-volume-31718/
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/
TradingView Blog
New built-in indicator: 24-hour Volume
Latest Updates to Track All Markets
🔥6👍3
🌲 #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.
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.
🔥10👍8👏1😁1
🌲 #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.
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.
👏10❤2👍1🔥1
🌲 #newfeature
To complement the recently introduced
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.❤5🔥3👏1💩1
👍5🥰2❤1💩1
🌲 #newfeature
`ta.change()` can now be called with a "bool" variable to detect state changes. You can now write:
`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)
🔥22👍6❤3💩1
🌲 #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:
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)
🔥23👍8💩2❤1