I'm trying to set Highs and Lows in 2 series at the same time, but can't seem to get the code right.
It should plot the entered high and low values at every intraday bar, for the specified date.
The code is designed to work with ticker SPX.
//@version=4
study("SPX 5", overlay=true)
// === FUNCTIONS ===
isDate(y,m,d) => year==y and month==m and dayofmonth==d
float lo = na
float hi = na
drawHiLo(y,m,d,l,h) =>
float ret1 = na
float ret2 = na
if isDate(y,m,d) and timeframe.isintraday
ret1 := l
ret2 := h
else
ret1 = lo[1]
ret2 = hi[1]
[ret1,ret2]
// === MAIN ===
[lo,hi] = drawHiLo(2020,04,13,2700,2770)
[lo,hi] = drawHiLo(2020,04,14,2800,2860)
plot(lo, style=plot.style_circles, color=color.lime)
plot(hi, style=plot.style_circles, color=color.lime)
The above script gives the following error: line 22: 'lo' is already defined.
I've tried several different approaches, but none seem to work.
Does someone have an idea on how to accomplish this?