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,
You can now change the values through the script's inputs. Added a few comments in code. Feel free to ask if what's going isn't clear:
//@version=4
study("SPX 5", overlay=true)
// Get values through Inputs.
spHi1 = input(2770)
spLo1 = input(2700)
spHi2 = input(2860)
spLo2 = input(2800)
// === FUNCTIONS ===
isDate(y,m,d) => year==y and month==m and dayofmonth==d
drawHiLo(y,m,d,l,h) =>
// Vars are initialized to na, so we only need to assign them a value when our conditions becomes true.
float ret1 = na
float ret2 = na
if isDate(y,m,d) and timeframe.isintraday
ret1 := l
ret2 := h
[ret1, ret2]
// === MAIN ===
// Make 2 separate call to function, but need to store results in different variables for each call.
[lo1,hi1] = drawHiLo(2020,04,13,spLo1,spHi1)
[lo2,hi2] = drawHiLo(2020,04,14,spLo2,spHi2)
plot(hi1, style=plot.style_circles, color=color.lime)
plot(lo1, style=plot.style_circles, color=color.lime)
plot(hi2, style=plot.style_circles, color=color.green)
plot(lo2, style=plot.style_circles, color=color.green)
Nice concept with the function, btw. Congrats.