All Questions
Tagged with pine-script arrays
77 questions
0
votes
1
answer
49
views
Array issues with pine script
I am writing a strategy for pine script and I keep getting the error code like the data cannot be retrieved.
I tried to find a new string to be able to retrieve the data but there's nothing that I ...
0
votes
0
answers
24
views
How can I set an alert on a condition met in an array in Pinescript
I have an array that is being set with divergences. What I want to do is add a conditional statement for IF the array contains cwmacd and macd together and another one that checks IF the array ...
0
votes
0
answers
29
views
Pine Script array syntax to display ROC on multiple instruments (BTC, ETH, etc)
The script below displays the rate of change (ROC) for multiple instruments (in this case, four BYBIT alt coins), as well as calculating the average ROC. It works, but I need some help with syntax to ...
0
votes
0
answers
55
views
Pine script to Find a closest value among a list of values
Request to review the below model
enter image description here
the averages were assigned in as A1, A2, A3 already
I wish to find the closest value to 0 among the array of average values and return as ...
0
votes
1
answer
104
views
Can I declare a dynamic-length array in PineScript?
I need to input a variable number of inputs into a PineScript to draw some price levels. The number of levels may vary day by day, sometimes I need 5, sometimes 7+. I want to declare an array in ...
0
votes
0
answers
28
views
Global scope, Local scope and an included Library
This script does recognize the Highs and Lows in [0][1][2] with referring to an Pivot-Array from the following library:
https://www.tradingview.com/script/bzIRuGXC-ZigZag/
Is there a possibility to ...
0
votes
1
answer
83
views
Do I need an Array? Trend-recognition
I don't get any further...
I want to recognize a trend and for this need to compare the lastLow and lastHigh to the Low and High before.
The High and Low I get from the ZigZag-library in TradingView.
...
0
votes
2
answers
46
views
the lowest low of some days
I'm trying to find a way to get a signal-point on the chart everytime the bar is a new 15-days low.
Thanks for help!
//@version=5
indicator('15-Days-Low', overlay=true)
bars_back = input(15)
ll = ta....
0
votes
2
answers
191
views
How to Run Plot Study for a Dynamic Number of Symbols Using Array and For Loop in Pinescript Tradinview?
I have created the following study, however I want to run it through a variable number of symbols using for loop and arrays.
//@version=5
// This Pine Script™ code is subject to the terms of the ...
0
votes
1
answer
41
views
A for loop using an array does not return the expected number
If you add the code below to the chart, it will count the 7 items that are set to true by default in the input, and 7 should be displayed in the tablecell.
However, tablecell displays 5 or 6 digit ...
0
votes
2
answers
79
views
In-Loop Assignment of Array Elements question -- why is one of my variables incorrect?
How come y≠x=z?
//@version=5
// I'M TESTING THIS CODE IN 1MIN TIMEFRAME
indicator("xyz")
x=array.new_float(2,na)
y=array.new_float(2,na)
z=array.new_float(2,na)
x.set(0,request.security(...
0
votes
1
answer
24
views
How to call upon the "second lowest" of a series of values?
Essentially what the title says, I have a series of code that looks at the values of 5 EMA's and I need to sort them and call upon different ones (the second lowest, or the middle EMA of the 5 for ...
0
votes
0
answers
41
views
Plotting Anchored VWAP from 5 days ago to the current bar
I have used published pine scripts to develope specific automation that I have in mind. I would like to plot Anchored VWAP starting from 5 days ago on 30 min chart (65 bars from the current bar). The ...
0
votes
1
answer
319
views
PineScript v5, working with arrays and for loops
I'm trying to write an indicator whose purpose is to identify support levels based on fractals.
This code shows conditions only for lower fractals (to make it easier to navigate the code).
The main ...
1
vote
1
answer
444
views
Running into a weird issue in Pine script array where length of array keeps on increasing
I am testing array feature in TradingView and trying to print data in a table. I am running into a weird issue where the length of the array becomes very large and am not able to figure out why.
I ...
0
votes
1
answer
305
views
Pinescript How can I replace source (close) from other symbol close in whole code to check if it meets the conditions?
So I created TradingView indicator which contains some of free indicators. It has a lot of conditions to plot the signal BUY, something about ten (160 lines). And - I want to get for example "...
0
votes
1
answer
211
views
Pine Script - Last bar with low value specified
I've been working on an indicator in Pine Script that involves identifying the last candle (closest to the current time) with a low value specified by the user. However, I'm encountering a challenge ...
0
votes
1
answer
285
views
Using saved values in Arrays
I am trying to use the values saved in the array called enterShortClose_arr and then check to see if the value is greater than the close when triggered again. The enterShortClose_arr values are ...
0
votes
1
answer
423
views
Plotting a label from an Array within Pinescript v5
I have this code that works well for Pinescript v5, but I am having trouble getting it to plot a label.
So what it does is it pulls technical data from the close of the data, then comapres it with ...
0
votes
3
answers
174
views
Array color to multiple values
Is there any way to shorten this using only two colors but having the second color fill the remaining values? I have a sorted 21 value table consisting of 1 variable color and 20 fixed colors.
color[] ...
0
votes
1
answer
69
views
Is it possible to add Incremental Labels?
I know it's possible to make this indicator faster and more efficient using arrays but the concept of being able to plot hundreds of lines and labels with incremental look backs sounds great at first.....
0
votes
1
answer
40
views
I am facing this problem and I don't know how to solve it ( Syntax error at input '[' )
fib_extension_levels = [0.0, 0.382, 0.618, 1.0]
The error is on the top line
error message : Syntax error at input '['
I tried to solve it myself but didn't know ...... Tried to solve it with chatGPT ...
0
votes
2
answers
650
views
Handling arrays when request.security_lower_tf for 1 minute does not return values for each 1 min bar
I'm working with individual bars from lower time frames, e.g. working with 1 minute bars on a 5 minute chart. In principle request.security_lower_tf(syminfo.tickerid, '1',close) should return an array ...
0
votes
1
answer
93
views
Declared type string is not compatible with assigned type string[] error
I am using the code below:
//@version=5
indicator("Currency Strength Indicator", shorttitle="CSI", overlay=false)
// Define the currency pairs to compare
var string ...
0
votes
1
answer
3k
views
How to create array of variables in pine script
I have created in tradingview (pine script) three Exponential Moving Averages and I want to create an array from such EMA's.
I have tried this:
//@version=5
indicator("My script")
ema3 = ta....
0
votes
2
answers
395
views
Data from array only exists for current bar. How can I reference historical values?
The script prints 2 labels on the current bar. These labels are the bullish and bearish probabilities of breaking a key level. I have split these strings to pull out just the percentage string value ...
0
votes
1
answer
142
views
PineScript Syntax error at input '['. How to solve it?
I'm trying to define an array of symbols in PineScript (v5) but it tells me Syntax error at input '['. Any idea what the problem might be? I've seen answers on array declaration with floats, but how ...
0
votes
0
answers
44
views
define the retracement levels and extension levels in pinescript v5
I am getting syntax errors at input when defining fiblevels and extension levels.
I am fairly new to PineScript and looking for help.
// Define the retracement levels
fibLevels = [0, 0.236, 0.382, 0.5,...
0
votes
1
answer
254
views
How to display Intrabar Values when using Lower Time frame?
I want to display last three close values of Intrabar when using Lower Time frame in Pinescript. The code I tried gives is not what I needed.
I am using 15 min chart and I need close of 3 min candle. ...
0
votes
1
answer
196
views
How to plot a shape under timesamps in an array when previous bar's close == timestamp
I'd like to plot a shape under the bars of each timestamp in the FOMC array. Logic is when previous bar close == timestamp date/time, then plotshape under that bar. The code below just plots a shape ...
0
votes
1
answer
446
views
Pine script Syntax error at input '[' array issue
I am working on pine script to display alert by looping through list of stocks. I am having issues to fix array related issue which is based on error thrown by the below code
Error at 10:0 Syntax ...
0
votes
1
answer
3k
views
Pinescript Arrays- multidimensional arrays
I am creating a neural net in Pine script which has two input neurons but I am having trouble creating a properly structured training data array. The net expects a two dimensional array. I am using ...
0
votes
1
answer
950
views
Pinescript plotting last values of array(array of last candle time)
Good day!
I have a question - how can i use line.new from array for the last updated array values?
When i use the array to plot line:
for x = 0 to (array.size(strong_levels_array) > 0 ? array.size(...
0
votes
1
answer
150
views
Make strategy with arrays in Pine
I'm trying to make a strategy of an indicator, but I get the error: Line 73: Cannot call 'operator >' with argument 'expr0'='call 'alertcondition' (void)'. An argument of 'void' type was used but a ...
0
votes
1
answer
277
views
How do I fix Syntax Error at Input in Pinescript?
Hey Im currently trying to build an indicator using chatgpt. Here is the code it gives me:
study("Volatility Factor", version=5)
// Number of bars to look back
bars_to_look_back = 20
// ...
-1
votes
1
answer
70
views
How to put a Horizontal Ray (hray) on every ema cross?
//@version=4
// Define variables
// 5 and 13 EMAs
ema5 = ema(close, 5)
ema13 = ema(close, 13)
// Use the crossover() function to detect when the EMAs cross
cross = crossover(ema5, ema13)
// Plot ...
0
votes
0
answers
107
views
Historical trend lines built with array and loop - strange issue with order of crossings of lines with varip counter - Tradingview - Pinescript
so I have an interesting issue. I put together a script, which draws historical trend lines using array and a loop. I then try to catch when each of the line is crossed and have an order of crosses, ...
0
votes
1
answer
723
views
How to access an array of UDT <type>
In the Pine script reference manual the is a code snippet on
https://www.tradingview.com/pine-script-docs/en/v5/language/Objects.html
I want to know how to access the values of the array ...
2
votes
0
answers
671
views
Drawing lines from pivot points that meet a specific conditions
I have successfully created a script that draws a line from one pivot point to another based on some conditions.
The conditions are:
The next (or following next) pivot points must have a high that is ...
0
votes
1
answer
390
views
Pinescript IF Statement Array
Hi i am struggling to get my array in Pinescript to produce anything other than a list of Nan. I am trying to create an array of the % difference of the low and 20sma when price bounces off the 20sma ...
0
votes
1
answer
1k
views
Separate Tuples Values and Assign in Pinescript TradingView
I was trying to display intrabar close values inside the current chart's bar(15 min). So there are three values. But the values comes as tuple.
I cannot separate the tuples to three values. I have ...
0
votes
1
answer
334
views
Loop array Alert only showing array 0
i have written a pinescript using array ( with parts borrowed from others). Once i put it up on tradingview and ran it is working but the problem is that when i get an alert, it sends the alert for ...
-1
votes
1
answer
1k
views
A way to have multiple price points in an array and then have a for loop go over the array and create a horizontal line at each price point
I made an array containing all of the price points that i had, and then I ran a for loop after that with a statement to create a horizontal line with each of the price points. This is my first night ...
0
votes
1
answer
31
views
I tried to record 24 green bar in br but I failed
n = input(24,title = "n")
gap = high - low
ret = close - open
greenbar = ret > 0
redbar = ret < 0
sr = array.new_float(0)
br = array.new_float(0)
for i = 0 to n-1 by 1
if greenbar[...
0
votes
1
answer
97
views
Push result into array after each loop iteration
How can we get the result for i=2 to be pushed onto index 0 of the array and i=3 to be pushed onto index 1? at the moment I am getting the SUM of i=2 + i=3 in index 0 and 1 as it shows on the image ...
0
votes
1
answer
193
views
Pushing the result of a counter onto an array for each for loop iteration
This is getting closer thanks also to mr_statler.
//@version=5
indicator("sma coun", overlay=false)
myArray = array.new_float(0)
var int counter = 0
for i = 200 to 201
if close > ta....
0
votes
2
answers
707
views
Is there a way to append several values to a Pine Script array in a single call?
I want to have a function within which several if conditions looking for specific integer values.
The function in some situations might be called several times in sequence in order to return the ...
1
vote
0
answers
35
views
Deleting / Recoloring a Line if it has been touched
I'm trying to create a Support and Resistance indicator that creates lines when we make a new monthly level and then recolors them when the bar closes, then recolors again if we have hit the level and ...
0
votes
1
answer
2k
views
Using the 'request.security_lower_tf' function, but the returned array size is 0
just like the code below, I was trying to get the lower timeframe data from 1 minute timeframe, but I got the error message:
In 'array.get()' function. Index 1 is out of bounds. array size is 0.
...
0
votes
1
answer
32
views
How can I use my plotted data in further calculations?
So I have this code that draws zigzag-alike line
indicator("Custom zigzag", overlay=true)
bullish(at) => open[at] < close[at]
bearish(at) => open[at] > close[at]
break_up() => ...