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
0
votes
1 answer
Pine script - how to plot so that it sticks to the edge of the view range?
TradingView has some indicators that stick to an edge of the chart window. An example of such indicator is the volume indicator and Visible Range Volume Profile indicator.
Is there a way to program my custom indicator so that it sticks to any of the…
0
votes
2 answers
Can we add webhook url directly inside the pinescript indicator/strategy?
I just created an indicator and also backtested it using strategy tester. Now I wish to run it automated with a 3rd party application. How can i add their webhook url in alert programmatically? any code snippets would be amazing!! I am new to…

user20537640
- 15
- 2
0
votes
1 answer
Pine Script VWAP issues
The following Pine script does not always reset VWAP at midnight. This is especially a problem when looking at bonds in the sub 1 minute scale.
I see it most on ZF in the 30 second scale. Seems to work fine most times on the 1 minute and higher…

Adrian Ortiz
- 5
- 2
0
votes
1 answer
Tradingview - PineScript - Convert Strategy from v2 to v5 but different outcome
So I was converting an old pine script v2 via on tradingview to v5 which all worked fine but when I came to use it, it gave me a different result to the v2 script once converted, . Same setting on input, properties but different…

Long token
- 5
- 2
0
votes
1 answer
Compilation error Line 7: Extraneous input '[' expecting ID
I understand the error message but i wanted to know why wouldn't this be something possible to do in pinescript?
[ [supertrend, direction], [middle, upper, lower] ] = request.security( 'BA' , 'D' , [ ta.supertrend(3, 10), ta.bb(close, 20, 2) ])

saleem
- 41
- 4
0
votes
1 answer
Tradingview bar color alert
I'd like to set an alert in Tradingview pinescript v5, if barcolor(color.green) is true. Can anyone help? Thanks much!
I'd like to set an alert in Tradingview pinescript v5, if barcolor(color.green) is true. Can anyone help? Thanks much!
0
votes
1 answer
Get high and low of previous condition candle
I am trying to figure out how to get the high and low of the most recent previous candle that meets one of my conditions. I know to get a prior candles high you can use the [1], but if I do not know the number of how far back the previous candle is,…

Spin
- 3
- 1
0
votes
0 answers
i want mix both the indicators, how to get center line 0 crossing to 50?
i want to remove crossing 0 line to be 50. for ex: rsi is 0 to 100 and crossing line is 50 in this indicator crossing line is 0 so i want it to be 50. so that i can add it rsi indicator.
//@version=5
//indicator(title='Divergence…

Munif Shaikh
- 1
- 1
0
votes
1 answer
Trying to understand how series work when scoped to a function in Pine Script
I understand about the series subscript, when in global scope, but just trying to get my head around how series work in functions. A good example is the built in "rma" script.
pine_rma(src, length) =>
alpha = 1/length
sum = 0.0
sum :=…

sambomartin
- 6,663
- 7
- 40
- 64
0
votes
2 answers
Why my trades are not getting triggered as often as the indicator shows signal on the chart?
I created an indicator and then want to use it to test in strategy but my trades are only 2 or 3 while the indicator shows so many in the chart, not sure what am i doing wrong?
strategy('AMI short', overlay = true)
ema5 = ta.ema(close,100)
rsi =…

user20537640
- 15
- 2
0
votes
2 answers
Using TradingView Pinescript only, is it possible to code a strategy that trades only after a confirmed winning trade?
I know it sounds weird, as a trade cannot be decided to be a win or a loss until it has been executed, but can we have our original strategy in the form of an indicator in the chart, and after having a win trade by the indicator, only our strategy…

Sewatech
- 13
- 3
0
votes
2 answers
PineScript doesnt calculate a SL, TP and quantity size properly
I need some help on a simple strategy code I have written. This is my 1st code on it.
I have an issue with mon code written on PineScript.
PineScript doesnt calculate my SL, TP and quantity size properly and I cannot figure out why.
My strategy is…

Ulrich
- 3
- 1
0
votes
0 answers
Close trade after a order in a opposite direction
How can you define a condition that if a order is closed by a opposite direction (long or short) two seperate orders are triggered? One long order to close the open short in this example and one additional long order?Like in this example i'm using…

kappamachine
- 17
- 4
0
votes
1 answer
i want to trigger an alert as soon as my current candle price cuts below the low of previous candle
i want to trigger an alert or plot hline as soon as below conditions are met:
the current candle did not cut the previous candle high
the current candle price cuts below the low of previous candle
the current candle is about to close (say 95% of…

user20537640
- 15
- 2
0
votes
0 answers
How to get Pinescript indicator to omit first 3 candles?
I have a script based on VWAP. Now VWAP starts at session beginning and is unreliable for first 2 15-minute candles. Since the script is based on VWAP, I need the script to record values only after say 9:45 AM i.e. disregard the first 2 15-minutes…

Arun Kumar Panda
- 13
- 4