I have this error message, here is the code:
for i = 0 to 3
day_time = timenow - i * 86400000
year_ = year(day_time)
month_ = month(day_time)
day_ = dayofmonth(day_time)
[asian_open, asian_close] = get_session_times(year_, month_, day_, asian_open_hour, asian_open_minute, asian_close_hour, asian_close_minute)
// Draw a rectangle for the Asian session
if (time >= asian_open and time <= asian_close)
var box session_box = na
var label session_label = na // Define the label variable
if (time == asian_open)
session_box := box.new(left=bar_index, top=high, right=bar_index, bottom=low, border_width=1, border_color=color.new(color.gray, 30), bgcolor=session_color)
session_label := label.new( //here is the error, on the (
x=bar_index,
y=high,
text="Asian",
xloc=xloc.bar_index,
yloc=yloc.abovebar,
textcolor=color.new(color.gray, 0), // Darker text color
size=size.small,
style=label.style_none,
textalign=text.align_center
)
box.set_right(session_box, bar_index)
box.set_top(session_box, math.max(high, box.get_top(session_box)))
box.set_bottom(session_box, math.min(low, box.get_bottom(session_box)))
// Calculate the horizontal center of the rectangle
middle_x = (box.get_left(session_box) + box.get_right(session_box)) / 2
// Center the label horizontally above the rectangle
label.set_x(session_label, middle_x)
label.set_y(session_label, box.get_top(session_box) + 10) // Adjust the vertical position as needed
New contributor
Ruben Bennetot is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.