I have a series myLine, which I fill with value na
myLine = 1==1 ? na : na // Series with na
Now I want to create a function that updates the myLine
series to have a value only on certain bars (intraday).
isDate(y,m,d) => y==year and m==month and d==dayofmonth ? true:false // Is the date of the current bar equal to the date provided by the parameters?
setMyData(y,m,d,lineValue) =>
if timeframe.isintraday and isDate(y,m,d)
myLine := lineValue
setMyData(2020,03,31,1234)
setMyData(2020,04,01,2345)
However, this doesn't seem to work, and I get this error
Cannot modify global variable 'myLine' in function.
I also tried using myLine[bar_index] := lineValue
but that doesn't seem to work either.
Does anyone know how to update values of a series only for certain datapoints?
I'm trying to plot horizontal lines only on certain dates (intraday).
I specifically want to use a series (instead of a line object) because that allows me to change to color in the styles tab.