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
0 answers

How to call security function for only the last candle in pinescript which is fetching a tuple

I am trying to call security function whose expression is a function call as shown: e.g. [o, h] = security(syminfo.tickerid, "D", f()) I want this to happen only for the present last candle so I am using if barstate.islast [o, h] =…
2
votes
0 answers

Buttons or hyperlinks on chart to change settings

I've been searching around and don't think this is possible yet but would be nice to have. Looking for a way to turn visibility on and off for options in a script faster. Currently you have to click through the cog, then on to inputs or style to…
2
votes
0 answers

Calculate/replicate RSI from Tradingview's pine script

Im trying to recreate Tradingviews pine script RSI code into Javascript code. But having a hard time figuring out how it works. I made the basic RSI using a normal moving average calculation. But the pine script uses exponential weighted moving…
Allart
  • 830
  • 11
  • 33
2
votes
1 answer

How to request data from another security to show correctly with request.security() - Pine Script v5 - TradingView

Does anyone know if it's possible to request string data using request.security() to get information on multiple symbols at the same time? The script I have compiles with no errors, but the problem is some of the data coming through in the alert…
Josiah
  • 53
  • 1
  • 2
  • 6
2
votes
1 answer

Convert String to Float Pine Script

Is it possible to convert String into Float or int in PineScript? We can use str.tostring to convert float to string, but is there a way to go from string to float or int? I want to try this as a workaround to offset value to the left. As I cant…
Lenon Fernandes
  • 33
  • 1
  • 1
  • 5
2
votes
2 answers

Pine Script - Buy/Sell indicator for TradingView that meets multiple conditions

I am trying to build a BUY/SELL Indicator for TradingView by using three indicators, EMA, MACD and Supertrend. Condition 1: The Fast EMA crosses up the Slow EMA. Condition 2: The MACD line is above the Signal Line. Condition 3: Supertrend is in…
Amlan Dutta
  • 372
  • 3
  • 7
  • 17
2
votes
1 answer

How to code MA change from previous candle?

I am new in pine script. I would like to format the given code for the table cells below: ema1 = ema[0] > ema[1] ? color.rgb(255, 255, 255, 10) : ema[0] == ema[1] ? color.rgb(88, 40, 65, 10) : color.rgb(0, 0, 255, 10) This shows the color of the…
ArchBack
  • 25
  • 5
2
votes
1 answer

Change tuple values when using a loop in pine script

In pine script I have a funtion that returns a tuple: calcSomething(val1, val2) => ... [val3, val4] And I'm calling the function from a loop where the val1 and val2 change: while i < 5 [val5, val6] = calcSomething(val1, val2) val1…
2
votes
0 answers

Pandas Exponential Moving Average (EWM) unable to copy classical tradingview EMA

I am trying to copy the functionality of classical EMA from trading. In trading view DOCS they say for EMA: It calculates by sing a formula: EMA = alpha * x + (1 - alpha) * EMA[1], where alpha = 2 / (y + 1) But what do I provide to EWM of Pandas…
luky
  • 2,263
  • 3
  • 22
  • 40
2
votes
0 answers

Conditions for entry

I am having a great deal of trouble today with a seemingly simple piece of code. I have 1 indicator giving an entry condition. How can I keep this entry condition open/ running until something cancels it. In essence what I want to do is, the first…
Francois
  • 21
  • 1
2
votes
0 answers

strategy with default_qty_type=strategy.percent_of_equity and default_qty_value=200 output same result as without leverage

While backtesting a pine strategy on tradingview I noticed that the docs allow to and use couple of options to set a leverage (just like you have on exchanges while trading futures/contracts). Hence, as per the docs recommendations, I added the…
gastngouron
  • 461
  • 1
  • 5
  • 15
2
votes
2 answers

What's the logic within LINREG function in pine (trading view)?

So i'm building some sort of charts in C#, i'm basically reverse-engineering what I need from TradingView functions which uses PineScript. I'm Kind of stuck with this one "LINREG" because there is no deep explanation on what's being calculated…
Yogurtu
  • 2,656
  • 3
  • 23
  • 23
2
votes
2 answers

All time high which is not recent

I am trying to modify script to get all time high date that is not recent. Eg: Apple made all time high on 15/10/2021 (last) 10/05/2017 (second last) ... and so on ... The problem is that this script is showing the recently ATH, I want ATH that…
Alex Fx
  • 61
  • 6
2
votes
1 answer

variable assignment in Pine script

I'm trying to read some pine script to understand how it works. But there is some strange thing I can't explain. For exemple for pivot pine script: pivotX_open = float(na) pivotX_open := nz(pivotX_open[1], open) pivotX_high = float(na) pivotX_high…
Batmanu
  • 23
  • 1
  • 4
2
votes
1 answer

How to get Pine script syntax highlighting in Atom

I want to work on script outside of trading view. Is there any plugins I can use to make coding in Atom more enjoyably for Pine script.
Kataboy
  • 21
  • 1