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
3
votes
1 answer

How to say current price in pine script

I have worked out the daily bars range, say from high-low. I want to be able to say 'From todays open, if the price goes up 50% of yesterdays range then go long. Saw some people say 'close' is the word for current price, but I don't want to wait for…
candlestickb
  • 37
  • 1
  • 6
3
votes
5 answers

How to find next adjacent bigger number from given list of numbers for an input number

I am trying to find next adjacent bigger number for an input number from given list of numbers. Please help me with Java code or algorithm to implement below. Given list of numbers = [50, 20, 40, 30, 10] Input number = 15 Output = 20 (next adjacent…
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
2 answers

using security function on tradingview, how to make the gaps smooth?

I am trying to plot multiple timeframe EMA on 15 min chart, this is my code. //@version=5 indicator(title='higher tf', overlay=true) // 4 hr show_4h = input(title='Show 4 hour', defval=true, group = "4 HOUR") show_ema20_4 = input(title='Show 20…
alex deralu
  • 569
  • 1
  • 3
  • 18
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…
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

TradingView STC vs any python STC

I am trying to use in a trading strategy the STC indicator, but I can not find out why its not working properly. The chart that I am using is BTC/USDT on UTC as a timeframe. Chart time: 01 Feb 22 - 16:20 UTC ------------------- TradingView:…
Mircea
  • 1,671
  • 7
  • 25
  • 41
3
votes
1 answer

How can use multiple indicators() in version5

I'm trying to use custom Stochastic and RSI in version5 but it only allows me to use 1 indicator in the script. I've tried using study but that doesn't work. How can I fix this? I've tried removing version version5 and using only study but that…
rohanx
  • 33
  • 5
3
votes
1 answer

Plot an array of labels

I would like to plot around 20 labels on a chart. I'll get the data in a CSV format. It will contain price, date and an id. So far I figured out how to plot a single label containing data from three arrays but I'm not sure how to loop through an…
Ando
  • 1,802
  • 4
  • 25
  • 47
3
votes
0 answers

How to plot spread of bid and ask spread in Tradingview using Pine Script?

I am not sure about the appropriate variable to extract bid and ask price of a stock/commodity. indicator("Spread - Bid Ask") bid_price= input(title="Symbol 1", type=symbol, defval= bid_price) ask_price = input(title="Symbol 2", type=symbol,…
Jack
  • 31
  • 2
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
3
votes
0 answers

Upload pine script to TradingView account via REST API

I was wondering if there is an REST API for TradingView to upload Pine script? I'd like to be able to push my scripts from my source control platform in automated fashion (i.e. GitHub Actions). Right now I can only upload the scripts manually via…
3
votes
1 answer

Pine script condition 1 and condition 2 fulfilled at up to n steps back

Say I have condition 1 and condition 2. If condition 1 and condition 2 was met within up to, say, 5 bars, then I want to perform some action. As an example let's say condition 1 was met at current close, and condition 2 was fulfilled 5 bars ago,…
User4536124
  • 37
  • 1
  • 11
3
votes
1 answer

Pine Script - Conditional Plot Style

I couldn't find an answer for this anywhere; not even in the official documentation. I've tried coding it myself but it's not working, so maybe it might not be possible. In the example below, you can plot with conditional colors: //STACKED EMAs …
MRYR
  • 72
  • 5