Reputation: 5
I'm writing a Pine Script Indicator and I'm getting 4 errors and one warning after compiling:
(1) warning: The transp
argument is deprecated. We recommend using color.new() or color.rgb() functions to specify the transparency of the plots instead. Additionally, note that transp
has no effect in plots where the color is calculated at runtime
This is my Pine Script Code:
'''
//@version=5
// Define the number of bars to be analyzed for finding clusters
clusterLength = input(title="Cluster Length", defval=100)
// Define the number of standard deviations from the mean to determine the cluster
stdDev = input(title="Number of Standard Deviations", defval=2.0)
// Calculate the mean and standard deviation for the defined number of bars
mean = ta.sma(close, clusterLength)
stddev = ta.stdev(close, clusterLength)
// Plot the upper and lower bounds of the clusters as horizontal lines
upperBound = mean + stddev * stdDev
lowerBound = mean - stddev * stdDev
hline(upperBound, color=color.red, linewidth=2, title="Upper Bound")
hline(lowerBound, color=color.blue, linewidth=2, title="Lower Bound")
// Fill the area between the bounds to visually represent the cluster
fill(upperBound, lowerBound, color=color.gray, transp=70)
'''
I would appreciate if you provide a solution. Thanks in advance
Upvotes: 0
Views: 4896
Reputation: 21342
You cannot use dynamic values in hline()
.
You can try using plot()
or line
instead.
And you should be calling the fill()
function with plot
s or hline
s. upperBound
and lowerBound
are just variables.
See the signature below:
fill(hline1, hline2, color, title, editable, fillgaps, display) → void
fill(plot1, plot2, color, title, editable, show_last, fillgaps, display) → void
Upvotes: 1