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
16
votes
2 answers
Indicator for current price in Pine Script
Is there a way to create an indicator which reflects the current price of a stock in Pine Script? I need this indicator because I need to enter an order before the candle closes (when there is a specific crossover) and the data for back testing is…

Aryagm
- 530
- 1
- 7
- 18
5
votes
1 answer
How to plot long and short positions like the ones using the drawing tool, from pinescript?
I'm trying to draw long and short positions like the ones on the image automatically using pinescript.

Karl
- 481
- 1
- 6
- 13
4
votes
2 answers
Get Value of MACD on different TimeFrame
How can you get the value of the Macd Line and Signal Line real-time from different timeframe. Like for example I am on a 4HR chart and I want to get the value of the Macd Line and Signal Line from the 1 hr timeframe.
I know how to get the value of…

Pablo
- 145
- 1
- 8
3
votes
2 answers
How can I track and plot the lowest price since entry of a short position?
I'm trying to track the low price since entry for my short positions as I have done with the high price for long positions. For some reason the reverse code does not work with shorts. The long/high plots fine. with different variations to my code I…

Olyboy
- 49
- 4
3
votes
1 answer
How Do I Calculate The Average Time For All Trades Of A Strategy?
Okay, there are two things I can't seem to do.
I need to calculate the time between all trades of the strategy (from each individual trade's entry to exit), then out of all of these, average them. Then, convert that output to minutes. Let's call it…

TheLegendOfA
- 43
- 8
3
votes
1 answer
Shift pinescript series by one
Suppose I have a pinescript series current that looks like this;
current = [1 0 0 1 0 0 1 0 0 1]
I want to shift this series backward by 1. The shifted variable will look like this;
shifted = [1 0 0 1 0 0 1 0 0 1 0]
The last sample of shifted will…

FDL
- 115
- 8
3
votes
1 answer
How do i check what symbol is currently open on the chart?
i am trying to implement different behaviors of the script depending on the current symbol that is opened, how do i check the name of the symbol?
for example (pseudocode):
if the symbol is CADJPY - do this
else if the symbol is NAS100USD - do this
user17585775
3
votes
1 answer
How to specify offset by time instead of bars? V5
Some of my rules (to detect something) gives false alarms for an hour after Market Open (or simply just not defined well enough anyways, ha-ha). Since I can locate the moment of Market Open, I can address bars relatively to it which is kinda cool.…

Vendrel
- 865
- 9
- 19
3
votes
4 answers
Sending a webhook AND and a message in Pinescript v5
It appears that through the alert() function you can code a message to be sent, but what about the webhook?
I would like to use capitalise.ai, and they require to set in the alert both a webhook (https://tvwebhook.capitalise.ai) and a message, for…

Giovanni Dominoni
- 71
- 2
- 7
3
votes
1 answer
Pine v5 - How to make dynamic text in plot text?
how to make dynamic text from input value into plotshape? Thanks
// Input
i_strat_longTPpercent = input.float(title="Long TP(%)", defval=3) / 100
// Plot
plotshape(longTPhit, style=shape.labeldown, location=location.abovebar, color=color.purple,…

podolkerod
- 95
- 2
- 8
3
votes
1 answer
How to plot after a certain date and ignore anything prior to - Pine Script v5 - TradingView
Does anyone know how I can plot each occurrence of a defined variable after a certain date? So, before a certain timeframe input ignore all occurrances. I was able to find this:How to plot only the last x periods
But, this appears to only plot a…

Josiah
- 53
- 1
- 2
- 6
2
votes
0 answers
How to Get the Last Bar Fixed open value pinescript?
Actually i Made a Pinescript of Plotting resistances but i want the resistances should be greater then the fixed last open. i want for all bars it should be the same last open fixed price
This is My Code
// This source code is subject to the terms…

Welder Pasha
- 43
- 3
2
votes
1 answer
How to Solve Pinescript Multi Symbol Strategy Error
Actually i want to make the screener of winrate of a specific strategy of all the symbols but i am not able to do that so please guide me
this is what i tried
// This source code is subject to the terms of the Mozilla Public License 2.0 at…

Welder Pasha
- 43
- 3
2
votes
0 answers
Pine Script Still Repainting with Best Practices?
I asked a similar question before here, but I thought I had figured out the issue, and couldn't provide visual representations of the issue, so posting again here as the issue isn't fixed.
This simple strategy (posted below) makes use of the…

windowshopr
- 138
- 7
2
votes
1 answer
Bybit Perp tickers ending with '.P', is there anyway to remove this?
I am attempting to automate my strategy and have added a comment into the strategy entry/exits with = "Buy {{ticker}} q=xxxx" as an example. I then use this {{strategy.order.comment}} in the alert message.
What returns is a ticker code like…

Durrr
- 23
- 2