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

Why is barssince not working in pine script v5?

I'm trying to check the last time rsi was over sold, but when i put in barssince(rsi < 30) the code is not blue, it's just white. Then when i save it comes back as "Could not find function or function reference 'barssince'." I read the language…
menamejaff
  • 39
  • 1
  • 4
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
2 answers

Get profit percent of last closed trades in Pine Script

im struglin to get the profit percent for a chosen number of last closed trades, any help is apreciated. Thanks in advance.
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

Ichimoku Cloud Alert Setup (PineScript)

I'm setting up an alarm system on ichimoku. I need four parameters for it to alarm but I was able to run three parameters. [OK] when the cloud on the right changes color, [OK] if the candle close is above the cloud, [OK] Tenkan-Kijun lines (blue,…
herijuana
  • 21
  • 2
2
votes
1 answer

How to get the proportion of time that has passed on current candle as a fraction?

I'm trying to get the proportion of time already passed at the current chart resolution of the current candle. For example, in the hourly timeframe, if the current remaining time on the candle is 45minutes, then I'd like to calculate "0.25" because…
Dan Rayson
  • 1,315
  • 1
  • 14
  • 37
2
votes
2 answers

How to force a waiting time of a few seconds between execution of commands in Pine? Need cooldown between close and open possition

A simple strategy script sends alerts to open and exit trades, that need to switch between long and short when conditions are met. Problem: Two alerts (e.g. exit short / enter long) are generated one after the other. Enter long fails, as the…
KarWil
  • 21
  • 2
2
votes
1 answer

Invalid argument 'display' in 'plot' call. Possible values: [display.none, display.all]

I am writing a pine script code to plot some lines conditionally. I see pine script v5, plot() function has display argument, still I am getting an weird error. Any idea what it could be? Code: //@version=5 indicator(title="Gann Levels",…
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
2
votes
2 answers

Pine script: ist it possible to evaluate next candle values? to get relative lowest

I'm trying to detect the if each candle is the lowest value, checking 5 previous candles lows and 5 next candles lows I found no problem with previous: if ta.lowest(low, 5) == low line.new(bar_index - 1, low, bar_index + 1, low, color =…
Juanan
  • 23
  • 5
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

How to get the second occurrence of a condition on pine script

I have a strategy in tradingview that enters every time this condition is true, but I only need to enter the second occurrence of this condition LongCondition = (wasOverSold and crossoverBull) and up_trend == false the LongCondition gets true only…
Davi A. Sampaio
  • 374
  • 2
  • 12
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, …