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

PineScript Multi TimeFrame indicator changes on changing time frame in TradingView

I am trying to develop a multi time frame indicator using pine script. I use the following line for choosing the prices based on which I can do further analysis. resolution = "D" source = security(syminfo.tickerid, resolution, close,…
3
votes
2 answers

How can I create a custom Class in Pine Script?

Is it possible to create a custom class in Pine and how can I create one? I have searched the web on how to make a class in Pine Script, but I have not found a single page. Here is a class example made in Python: class Person: def __init__(self,…
Marcus Cazzola
  • 313
  • 1
  • 9
3
votes
1 answer

check if variable is NA

I use pine script and I want to check if some variable is NA. Say: float value = na if value == na // do something As far as I am aware, the manual says that it is not guaranteed to work. Are there any alternatives to check if a variable is NA?…
3
votes
1 answer

How to import trades history in Tradingdview with pine editor?

I'm trying to import some buys and sales into the chart. Ideally I would like to mark the candle and show the amount but I have two issues. The first is that I keep getting "Array is too large. Maximum size is 100000" When I add many trades ( around…
chifliiiii
  • 2,231
  • 3
  • 28
  • 37
3
votes
1 answer

Pine Script volume data does not match when using security() to retrieve volume

I am trying to pull volume of stocks from different securities to analyze them. However, the volume from the security() command seems different to the standard volume command. I have made sure they are part of the same timeframe. My code is…
mingos
  • 31
  • 3
3
votes
0 answers

Using external data in Trading View

I have developed an AI model using python that predicts the future price of crypto/stock. I would like to make use of the output of this model in Pine Script. I was initially hoping that I would be able to make an API call to my model, but I quickly…
user11686916
  • 31
  • 1
  • 2
3
votes
1 answer

Covert String to integer in Pine script

I would like to convert input.resolution into an integer represented as hours The function parameter resolution captured from the input() function Below is the custom function f_getLookbackNumber(resolution) => resolutionHours = iff(resolution…
neo-technoker
  • 369
  • 2
  • 8
  • 26
3
votes
1 answer

PIne Script - EMA into a 'Checkbox' Boolean input?

sorry for being such a newb and asking this silly question but does anyone know how to turn an EMA into a toggle switch (checkbox) input in TradingView? Example - having an EMA 200 line drawn unto the chart and having the option to open the settings…
Kris
  • 33
  • 4
3
votes
1 answer

Pine Script - Tradingview Draw a daily rectangle

I'm working on a TradingView script (Pine) and I would to develop a simply script that draw a rectangle from a start of current day to the end based on my current timeframe from Monday To Friday... Example: First rectangle drawed from 24/03/2021 to…
bbgg2017
  • 187
  • 3
  • 10
3
votes
1 answer

The function "max_bars_back" is not working as expected

my expectation in the code below is that the "max_bars_back" will limit the history used for the indicator to 500 bars, but this seems to not work as intended. Do anyone have a suggestion for how this could be fixed? //@version=4 study("Green Bars…
3
votes
2 answers

"Stop - Calculating Error" Problem with creating an alert on strategy

can you help solve this problem ?! I have a strategy and it works well, the problem is that I added some additional input source to it (it is plot from a study script.) type = input.source and when I want to alert it, I receive" this message,…
Armin
  • 33
  • 8
3
votes
1 answer

How to trigger a label based on a condition being true, but only once

I'm new to Pine script so bear with me. I'm trying to figure out how to plot a buy label when a "long" condition becomes true, but only the first time and not for every bar that the condition is true. So basically, the same way "strategy.entry" and…
adamio
  • 57
  • 1
  • 4
3
votes
5 answers

How to view errors/toggle log window in pine script editor?

Maybe a stupid question. I'm new to TradingView and pine script, so please bear with me if there's some simple way to do this... I figured out how to copy and modify a script from the library. At first, I could see a tiny edge of a window at the…
leanne
  • 7,940
  • 48
  • 77
3
votes
1 answer

Pine script series[string] to string conversion

I am trying to read symbols (strings) from an array, but array.get returns a series[string] object, while security only accepts simple strings. I tried casting to string, but it still gives a "series[string] argument is not accepted" error. Is there…
Will Bir
  • 35
  • 1
  • 4
3
votes
2 answers

how does the pine-script linreg function work

i want to transfer a pine-script linreg function to php, and i need some help which values are exactly passed to the linreg function. i.e. my linreg function in pine-script looks like this: linreg(close, 20, 0) for calculating the linear regression…
Lukas F.
  • 55
  • 8