How can I draw a 5 min bar candle over 1 min bar chart? (see attachment yellow box)
If I am setting DefParam DrawOnLastBarOnly = true then the following code shows the rigth solution. How can I addapt this code for the hole chart, not only the last 5 bars?
DefParam DrawOnLastBarOnly = true
hh5 = highest[5](high)
ll5 = lowest[5](low)
a=0
for i = 0 to 4 do
x1 = barindex[a]
x2 = x1 -4
DRAWRECTANGLE(x1,ll5,x2,hh5)coloured(255,255,0,275)
next
Thanks for your support.
Check if this simple code does the job :
//plot 5min open-close box over 1 min chart
timeframe(5mn,updateonclose )
m5open = open
m5close = close
timeframe(default)
if openminute mod 5 = 0 then
if m5open < m5close then
r=0
g=255
else
r=200
g=0
endif
drawrectangle(barindex-5, m5open, barindex-1, m5close) coloured(r,g,0,32) bordercolor(r,g,0,60)
endif
return
Just run it on 1 minute chart. Hope it helps!