I am trying to write a Pine Script function that will take a series of data (e.g., [1, 2, 3, 4, 5, ..., 100]
) and return a new series where every element is replaced by the highest value in the input series (in this case, [100, 100, ..., 100]
).
Here is what I have so far:
highest(data=close) =>
// need the highest number for each array element of ALL, NOT just before that value
Currently, highest()
only considers the highest value up to the current point in the series. However, I need the function to evaluate the highest value across the entire series and use that value for every element.
What I’ve tried:
- Using
ta.highest()
, but it only works for the highest value up to the current element, not for the entire series.
Goal:
To transform an input series like [1, 2, 3, 100(maximum),...34]
into [100, 100, ..., 100]
.
How can I achieve this?