I am trying to make box.new from a higher timeframe to the current timeframe.
I wrote the following code for plotting weekly box on daily but its not happening.
It is working fine on the same (weekly) timeframe.
I also tried to use the drawBox Function in security function, that does not work.
Help appreciated!
//@version=5
indicator("SR (NEW)", "SR (NEW)", true, max_lines_count = 500)
// Getting the bar values
type OHLC
float o
float h
float l
float c
// float prevC
makeOHLC(int bb = 0)=>
OHLC.new(open[bb], high[bb], low[bb], close[bb])
ibar = request.security(syminfo.tickerid, "W", makeOHLC(0), lookahead=barmerge.lookahead_on)
// Drawing box
drawBox(left, right, top, bottom, diff, extend = extend.right) =>
drawnBox = box.new(left, top, right, bottom, extend = extend)
if diff == "res"
box.set_border_color(drawnBox, #f4433666)
box.set_bgcolor(drawnBox, #f4433633)
else
box.set_border_color(drawnBox, #00968866)
box.set_bgcolor(drawnBox, #00968833)
drawnBox
// Intermediate Timeframe
isrc = (ibar.h - ibar.l) / 2 > math.abs(ibar.o - ibar.c)
ibullCandle = (ibar.c > ibar.o and not isrc)
ibearCandle = (ibar.o > ibar.c and not isrc)
ibull1ContiSupp = ibullCandle[1] and isrc[2] and ibullCandle[3]
if ibull1ContiSupp
drawBox(bar_index[2], last_bar_index, ibar.h[2], ibar.l[2], "sup")
I also want to remove the boxes whos lows have been broken