Questions tagged [pine-script]

Pine Script is a domain-specific language for coding custom technical indicators and strategies on TradingView. Use this tag for questions related to programming in Pine Script. Please do not use the [tradingview-api] tag for Pine-related questions.

Pine Script is a domain-specific language for coding custom technical indicators and strategies on TradingView. Use this tag for questions related to programming in Pine Script.

6637 questions
49
votes
6 answers

What is the equivalent of console.log in pine-script?

Is it possible to console.log variables, or the results of function invocation in pine-script? I'd like to convert a pine-script script into JavaScript, and I'd like to verify pinescript variables I'm moving into JavaScript are have the same value…
zero_cool
  • 3,960
  • 5
  • 39
  • 54
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…
15
votes
2 answers

Tradingview's auto fit scale function: exclude drawings of an indicator

I've got an indicator which automatically compresses the whole price chart on the y-scale, so I have to leave it invisible most of the time. Even a doubleclick on the y-scale (chart auto fit function) includes all visible indicators. Is there any…
cody
  • 6,389
  • 15
  • 52
  • 77
13
votes
3 answers

pine script with two indicators one overlaid on the chart and another on its own?

I am trying to write a pine script with two indicators one overlaid on the chart (EMA) and another on its own?(Stoch) I cannot seem to find any info on how to separate these (Visually) but keep them within 1 pine script, ie to be able to take…
Brandon Saccone
  • 139
  • 1
  • 1
  • 3
12
votes
1 answer

Using Pine Script is it possible to add some external data from some file to the TradingView chart?

What I have in mind is that I would like to have a view of Open Interest data along with the price chart so that alongside chart patterns would also get the view of where the action in Open Interest is happening. Everyday NSE India provides file…
anifunny
  • 121
  • 1
  • 1
  • 3
11
votes
2 answers

Tradingview Pine script - how can I make custom volume indicator behave like a built-in Vol

I made a custom volume indicator, but when applied to the chart, it doesn't autoscale like the built-in one, doesn't auto stick to the bottom of the chart panel, nor can it go without its own explicit extra scale on the side. Is there a way for it…
user3675185
  • 111
  • 1
  • 1
  • 3
11
votes
3 answers

How to optimise parameters in a TradingView Pine script?

I want to optimise indicator parameters in a TradingView Pine backtest. This is possible with other tools, but when I search for this functionality in TradingView I don't find anything. Can anybody please help? If it isn't possible in TradingView,…
10
votes
2 answers

Hide trades on chart, quantity and signal labels in code tradingview

I am looking for a way to hide: trades on the chart, quantity, and signal labels - When using a pinescript strategy for trading view. I want to do this in the code and not in the settings window. At the moment I have to uncheck the boxes every time…
10
votes
2 answers

How to Change global variable from function in pine script?

i am trying to write a script to get gann square of 9 levels. I have done it another languages but cant understand the pine script here it says Cannot modify global variable in function. Is there any solution to get the value here is my…
Mijanur Rahaman
  • 353
  • 1
  • 5
  • 19
10
votes
3 answers

Angle of Line in Pine Script

I would like to find price trend for last 200 bars in TradingView Pine Script language. I want to draw a line from latest bar (close) to 200 bars older one. Then I want to calculate the angle of the line in degrees to see how much bullish or bearish…
Phillip
  • 259
  • 1
  • 2
  • 11
9
votes
4 answers

How to implement RSI Divergence in Python

I was wondering is there any Python library that covers RSI-Divergence (difference between a fast and a slow RSI) or any guidence about how can I implement its algorithm in Python. Already asked question: Programmatically detect RSI divergence. One…
alper
  • 2,919
  • 9
  • 53
  • 102
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
9
votes
2 answers

Pine-Script + Multiple Symbol Strategy

I would like to know if it is possible in TradingView to backtest multiple Symbol in the same script ? In other words, stand out from the symbol applied to the graphic. I found how to call other symbol with the commande security, but after to place…
guerin remi
  • 115
  • 1
  • 7
9
votes
4 answers

how to draw lines in Pine script (Tradingview)?

Pine editor still does not have built-in functions to plot lines (such as support lines, trend lines). I could not find any direct or indirect method to draw lines. I want to build function that look like below (for example only) draw_line(price1,…
Ibrahim
  • 109
  • 1
  • 1
  • 5
8
votes
1 answer

TradingView – Multiple take profits for a single order in Pine Script

I'm trying to implement a simple strategy where I enter a long when I receive a buy signal, then I want to take multiple profits and set a stop loss : Sell 25% quantity at 1% profit Sell 25% quantity at 2% profit Sell 25% quantity at 3% profit…
Jul
  • 1,039
  • 3
  • 12
  • 20
1
2 3
99 100