ar
Feedback
PineCoders Squawk Box

PineCoders Squawk Box

الذهاب إلى القناة على Telegram

News & Tips on TradingView's Pine programming language

إظهار المزيد
3 493
المشتركون
لا توجد بيانات24 ساعات
+157 أيام
+4730 أيام
أرشيف المشاركات
🐞#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.

🌲 #newfeature When saving an indicator template, you can now associate a symbol to it.
🌲 #newfeature When saving an indicator template, you can now associate a symbol to it.

🌲 #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 New label styles now allow you to position the label pointer in any direction when creating labels in Pine. ht
🌲 #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 A new set of Candlestick Patterns built-in indicators was added. Have a look at the new tooltip= argument to t
+1
🌲 #newfeature A new set of Candlestick Patterns built-in indicators was added. Have a look at the new tooltip= argument to the label.new() function be used in there, which you can also change dynamically using label.set_tooltip(). https://www.tradingview.com/pine-script-reference/v4/#fun_label{dot}new

🌲 #newfeature The syminfo.basecurrency variable was added. It returns the base currency of the current symbol, so "EUR" for "EURUSD". https://www.tradingview.com/pine-script-reference/v4/#var_syminfo{dot}basecurrency

🌲 #newfeature Previously, second, minute, hour, year, month, dayofmonth and dayofweek always returned time in the exchange's time. A new timezone= parameter was added to them so you can now retrieve the bar's time in any timezone. https://www.tradingview.com/pine-script-reference/v4/#fun_hour

🐞#bug The textalign= parameter defaults to center, regardless of the argument you use, when you create a label. Until the problem is fixed, there is a workaround:
//@version=4
study("")
if bar_index % 5 == 0
    // Alignment doesn't work here.
    _b = label.new(bar_index, high, "T\nTTTTT", textalign = text.align_right)
    // Works here.
    label.set_textalign(_b, text.align_right)

💪 #tip When using security(), the way we achieve repainting or non-repainting needs to take into account the context of that function's call. These are your 2 options:
//@version=4
study("", "", true)
repaint   = security(syminfo.tickerid, "D", close)
noRepaint = security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
plot(repaint,   "repaint",   color.green, 8, transp = 70)
plot(noRepaint, "noRepaint", color.green, 2)
Again, it is critical NOT to mix up using no offset to the series as in the repaint case AND using lookahead = barmerge.lookahead_on, as this will produce lookahead bias by using future data. https://www.tradingview.com/x/H0gjYIDP/

💪 #tip To repaint or not to repaint? Traders ask script authors all the time if our scripts repaint, as if it was something inherently bad, which it isn't. The decision to code a repainting or non-repainting signal is yours to make, and should be based on your design, your calculations, what features you want to offer users of your script, and how you intend alerts to be used with your script. The best option is often to provide users with a Repaint/No Repaint choice, but that is not always possible. Note that a simple RSI like:
r = rsi(close, 14)
plot(r)
is a repainting signal, as the value of r will vary during the realtime bar. Also note that if your users ask for a non-repainting version of that plot, then you will need to plot a late signal, and so users should realize this. They can't have their cake and eat it too: non-repainting signals are by definition late, like this:
r = rsi(close, 14)[1]
plot(r)
or this equivalent code:
r = rsi(close[1], 14)
plot(r)
or this one:
r = rsi(close, 14)
plot(r[1])
Which version you will use will depend on your needs and the code's context.

💪 #tip When using security() and you want to avoid repainting, remember that it's critical to use two techniques TOGETHER: 1. Offset the series with [1] 2. Use lookahead = barmerge.lookahead_on
noRepaintAndNoFutureData  = security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)

We see code in scripts that uses lookahead on but doesn't offset the series, which produces 2 adverse effects: a) Future data is used on historical bars, which let's your script cheat and misleads traders, as there is no way your code can reproduce that behavior in realtime, because there are no future bars to cheat with then. b) The value will repaint in realtime.
//@version=4
study("", "", true)
noRepaintAndNoFutureData  = security(syminfo.tickerid, "D", close[1], lookahead = barmerge.lookahead_on)
repaintsAndUsesFutureData = security(syminfo.tickerid, "D", close,    lookahead = barmerge.lookahead_on)
plot(noRepaintAndNoFutureData, "Good", color.green, 2)
plot(repaintsAndUsesFutureData, "Bad", color.red, 2)

https://www.tradingview.com/x/hkfEyExW/

🌲 #newfeature You can now Search & Replace in the Pine Editor. https://www.tradingview.com/blog/en/find-and-replace-in-pine-
🌲 #newfeature You can now Search & Replace in the Pine Editor. https://www.tradingview.com/blog/en/find-and-replace-in-pine-editor-18848/

🌲 #newfeature We now have alerts on strategies! Pine coders can use the new alert_message= parameter in order-placing strategy.*() calls to define an alert message that varies with each type of order. Please read feature specs carefully. https://www.tradingview.com/blog/en/strategy-alerts-are-live-now-18770/

🔈 #news alexgrover has added Ema() and Atr() functions accepting series lengths to his brilliant Functions Allowing Series A
🔈 #news alexgrover has added Ema() and Atr() functions accepting series lengths to his brilliant Functions Allowing Series As Length script published from the PineCoders account.

💪 #tip Ever wonder how the Strategy Tester values are calculated? This doc explains it all.
💪 #tip Ever wonder how the Strategy Tester values are calculated? This doc explains it all.

🌲 #newfeature Premium accounts can now control the expiry date on access to their invite-only script publications. See the b
🌲 #newfeature Premium accounts can now control the expiry date on access to their invite-only script publications. See the blog post.

🌲 #newfeature else if The else if structure is now allowed!
//@version=4
study("")
a = 0
if close > open
    a := 3
else if close < open
    a := 2
else
    a := 1
plot(a)

🔈 #news midtownsk8rguy has updated his color chart. Labels make it easier to identify colors. This is a good and pretty complete selection of colors that work well: https://www.tradingview.com/script/yyDYIrRQ-Pine-Color-Magic-and-Chart-Theme-Simulator/

🌲 #newfeature A new resolution= parameter to study() provides coders with a simple way to give their script MTF functionality without using security(). See how the "Moving Average" built-in from the Editor's "New" menu uses it. Make sure you are comfortable with the feature before publishing scripts using it. The HTF values returned contain gaps.