This tag should be used for questions relating to scripts and code built specifically on version 5 of Trading View's Pine Script language.
Questions tagged [pine-script-v5]
2372 questions
1
vote
1 answer
How can i combine RSI and Nadaraya-Watson Envelope
I'm new to programming in Pine Script language and I'm trying to combine the RSI indicator with the Nadaraya-Watson Envelope by LuxAlgo. The strategy basically is that when the price crosses the upper channel and the RSI indicates overbought, it…

Leandro Martin Bado
- 11
- 1
1
vote
1 answer
TP/SL Order does not execute in Pine Script
I place the order using the following code and it gets executed without any problem:
//place order
` strategy.entry(
currentOrder.orderEntryId,
direction = longCondition ? strategy.long: strategy.short,
…

Zoran
- 21
- 2
1
vote
1 answer
I have created a multi Zig Zag indicator in Pine Script , and can't figure out how to allow the user to toggle each Zig Zag line on/off
I have created a multi Zig Zag indicator, and can't figure out how to allow the user to toggle each Zig Zag line on/off.
Here is the code...
//@version=5
indicator('Multi Structure Zig Zag', max_lines_count=500)
length = input(100, title='Structure…

self2point0
- 11
- 3
1
vote
3 answers
Alert in pinescript
i want to add alert while buy / sell signal generated.
Below is my pinescript.
//@version=5
indicator(title='TEST08032023', overlay=true)
s9ema = ta.ema(close, 9)
s18ema = ta.ema(close, 18)
longCond = ta.crossover(s9ema, s18ema)
shortCond =…

Rashmi Rahul
- 11
- 3
1
vote
1 answer
Warning message "...strategy.close()` with a `when` parameter as the second argument" but not using when
Pinescript now states after compiling:
The script uses a deprecated overload of strategy.close() with a when parameter as the second argument. When calling this function with only positional arguments, use a string for the second argument to avoid…

krueger17
- 11
- 1
1
vote
1 answer
no viable alternative at character '{'
I keep getting this error message
no viable alternative at character '{'
when trying to compile my code in pinescript version 5.
My code is as follows:
// Create alerts based on candle close type and input
if syminfo.ticker == symbolToMonitor and…

Ola
- 11
- 1
1
vote
1 answer
Pinescript V5 - Multi-stage alerts across different bar indexes
I want to trigger an alert after 2 or more conditions are satisfied, but are not occurring at the same time.
For example:
Stage 1: RSI above 70
Stage 2: Close above Keltner Channel
Stage 3 & trigger: Close below EMA10
For stage 3 to trigger, it…

Adam Lambert
- 1,311
- 3
- 24
- 45
1
vote
0 answers
Bug or feature? Is there any logic behind this behaviour of user defined types?
why plot(p.x) behaves differently from plot(y) (please see the comments in the script below):
//@version=5
indicator("My script")
type pp
float x
p = pp.new(1)
p.x :=1
y = 5
plot(p.x) // plots 1
plot(y) // plots 5
p.x:=2
y := 6…

Moebius
- 329
- 1
- 7
1
vote
0 answers
Pine Script function ta.change return value when use with math.sum
first of all, I am writing Kaufman's Adaptive Moving Average (KAMA), and I am struggling with the calculation of Efficiency Ratio (ER).
First of all, let me explain the calculation of efficiency ratio.
ER = Change/Volatility
Change = ABS(Close -…

T K
- 13
- 4
1
vote
0 answers
'NA' does not work with and 'AND' logical pine script
My script does not working as expected when I put a 'NA' variable in 'AND' logical.
// ON/OFF Indicator
// Buy Condition
MACDonoffbuy = useMACD ? macdLine > 0 : na
ADXonfoffbuy = useADX ? ADX > thradx : na
RSIonoffbuy = useRSI ? rsi >= overbought…

Ardani Hendarta
- 11
- 1
1
vote
0 answers
How can i make fair value gap boxes and hide when filled automatically? calculation would be low[0] > high{-[2]
Fair value gap coding in pinescript?
I have tried to write code but unable to add more functions on it.
//@version=5
indicator('Fair Value Gap Akash Mehto', overlay=true)
boxLength = input.int(title='boxLength', defval=6, group='General',…

Fallen Angel
- 11
- 1
1
vote
1 answer
Pine Script version 5 - style=plot.style_line is plotted as interrupted line
I made a pine script for trading view indicator. I want it to plot an uninterrupted line, however I see interrupted line (dashed line) being plotted. I don't know how to resolve this.
I follow the pine script Version 5 user manual on tradingview,…

Nawid Daliry
- 15
- 3
1
vote
1 answer
How can I convert a false overlay Oscillator into a true overlay with Buy/Sell Signals in pinescript version 5?
I need to plot labelup and labeldown signals whenever rsi with lenght 21 crosses an SMA with lenght 5. Originally, they are Oscillators with overlay set as false. All I just need is the correct syntax for the crossover and the Buy/Sell Labels…

Emmanuel Okenwa
- 13
- 3
1
vote
1 answer
How to start coding for pattern detection?
I am trying to write the code to find the following pattern anywhere in the chart.
It is very hard for me to understand how to do it or how to start or how to think about coding it.
As an example, I want to detect the following pattern, where there…

sey eeet
- 229
- 2
- 8
1
vote
0 answers
"If can not return String when Series is used inside it" Pinescript v2 error
I have been trying to write some code, and I came up with this so far, but I am not being able to figure out the error that it keeps outputting. "'if' can not return String when Series is used inside it" I tried to correct the If statements but it…

LJ2
- 11
- 2