Hi,
I want to draw a horizontal line of the weekly open price as a horizontal line and a vertical line each Monday (my opening day of the week) on a chart. I’ve looked and can’t see how I can get the opening weeks value to draw using DRAWHLINE.
Any help would be grateful.
There you go (not tested):
IF OpenDayOfWeek = 1 AND OpenDayOfWeek[1] <> 1 THEN
DRAWVLINE(BarIndex) coloured(255,0,0, 255) //RED vartical line
DRAWHLINE(open) coloured(0,128,0, 255) //GREEN horizontal line
ENDIF
RETURN
Using DRAWHLINE will result in a mass of lines across your chart.
Better to use DRAWSEGMENT like this
if opendayofweek = 1 and opendayofweek[1] <> 1 then
myopen = open
drawvline(barindex) coloured(255,0,0, 255)
endif
if myopen = myopen[1] then
drawsegment(barindex,myopen,barindex-1,myopen) coloured(0,128,0, 255)
endif
return
Thanks guys for your assistance. Sorry for the late response.
Hello,
Best wishes for 2026.
Is there a way to get it for weekly close too ?
I tried to draw that segment on the previous week close, in vain. I am really not good as this language …
Thanks in advance.
This version is updated for the previous week CLOSE:
if opendayofweek = 1 and opendayofweek[1] <> 1 then
myclose = close[1]
drawsegment(barindex,myclose,barindex+1,myclose) coloured(0,128,0, 255)
endif
if myclose = myclose[1] then
drawsegment(barindex,myclose,barindex-1,myclose) coloured(0,128,0, 255)
endif
return