Questions tagged [pine-script-v4]

Pine Script is a scripting language designed by TradingView. It allows users to create custom indicators and run them on their servers.

Pine is a lightweight language focused on the specific task of developing indicators and strategies. Most of TradingView’s built-in indicators have been coded in Pine.

See documentation of Pine Script v4

665 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…
9
votes
10 answers

How pivothigh() and pivotlow() function work on Tradingview Pinescript?

I'm trying to rewrite a script to Python, but I can't figure out how pivothigh() and pivotlow() function work, and I can't find source code, I know how to calculate Pivot Points, but what leftbars and rightbars means in this two function? Please…
Inso
  • 837
  • 1
  • 7
  • 11
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
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
3 answers

How to get bar index on specific date

I am new to pine script. I want to compare the prices on 2 specific date. But how would I get the bar_index on a particular date? Thanks in advance
Max Cheung
  • 176
  • 3
  • 13
2
votes
1 answer

Pine script to python Conversion

I've been trying to convert the following Pinescript to Python without much success. I want to convert the below pine script code to python can someone plz help me out. avg= ema(abs(x - x[1]), t) smoothrng = ema(avrng, wper) * m
user20081578
  • 21
  • 1
  • 3
2
votes
1 answer

"Highest value offset for a given number of bars back" meaning?

I'm new to Pine script, please, anyone explain me exactly what this high[abs(highestbars(amplitude))] statement returns, specially in highestbars(2) definition what it mean Highest value offset?? FYI this statement is from Tradingview.com HalfTrend…
2
votes
1 answer

In tradingview, pine script function strategy.exit doesn't work if take profit and stop loss were set separately instead of a single line

The following code works for me when I try to set the stop loss and take profit level: strategy.exit("TP/SL 1", "Long Entry 1", stop = long_stop_level, limit = long_profit_level) But the issue for this code is that it will not tell me it is a…
jguy
  • 161
  • 1
  • 11
2
votes
1 answer

How do I plot a horizontal line on the high and low of a specific time in Pinescript?

My question is really two parts. How do I plot a horizontal line (that extends to the right but not the left) starting at a specific time of the day, outside of trading hours. I want to plot two horizontal lines actually, one on the high and one on…
2
votes
1 answer

Per chart indicators created using pine-script in trading view (like the drawings)

I created a custom indicator in trading view using pine-script. The inputs to the indicator depend on the chart that is open. Also I do not want the indicator visible in all charts. Basically what I want is to indicator behave like the drawing…
2
votes
1 answer

(Tradingview - Pine Script) Convert iff Function to v5 error

I tried to convert pine v2 iff function to v5 but I kept getting this error: line 32: Undeclared identifier 'vwapsum'; line 33: Undeclared identifier 'volumesum'; line 34: Undeclared identifier 'v2sum' this one is original v2 script: newSession =…
podolkerod
  • 95
  • 2
  • 8
2
votes
1 answer

Show/Hide Barcolor from Input Settings

how to make checkbox option to Show/Hide in Input Settings (so we don't need go to input style tab to show/hide it) for bar coloring with conditional below? //Conditions L_adx = DIPlus > DIMinus and ADX > th S_adx = DIPlus < DIMinus and ADX >…
podolkerod
  • 95
  • 2
  • 8
2
votes
1 answer

How to use barstate.islastconfirmedhistory

Can you please explain how to use barstate.islastconfirmedhistory ? Can anyone create a sample program where the below built-in variable is used? barstate.islastconfirmedhistory
rohan sawant
  • 121
  • 1
  • 14
2
votes
1 answer

Problem to convert to pinescript V4 or V5

I have this code in my account and it works fine but I can not publish it. I'm having a very hard time converting this script to the version 4 or 5. study(title="Wolf Trade", overlay = true) adverupgrade = input(defval=true, …
1
2 3
44 45