I have the following indicator that I defined.
I would like to fix the timeframe so it always show me the output/results of the 1D
timeframe no matter what timeframe I am in.
I tried to wrap in a func, but I failed.
I also tried to fixed the timeframe, but I was not successful.
I appreciate it if someone can help me with it.
Thanks
//@version=5
indicator("FVG", shorttitle="FVG", overlay = true, max_boxes_count = 500)
// string tfInput = input.timeframe("")
IsDeleteBoxes = input.bool(false, "Deleted Used boxes")
var box boxUp = na
var BoxesInformation = array.new_box(0)
var AllBoxes = box.all
if (low[0]>high[2])
if (low[2]<low[1] and high>high[1])
boxUp := box.new(bottom=high[2], left=bar_index[2], top=low[0], right=bar_index[0], bgcolor=color.rgb(43, 43, 43), extend = extend.right, border_color=color.rgb(131, 141, 141))
AllBoxes := box.all
else
if array.size(AllBoxes) > 0
for i = 0 to array.size(AllBoxes) - 1
if (box.get_top(array.get(AllBoxes, i))>low and not array.includes(BoxesInformation, array.get(AllBoxes, i)))
box.set_extend(array.get(AllBoxes, i),extend.none)
box.set_right(array.get(AllBoxes, i),right=bar_index[0])
box.set_right(array.get(AllBoxes, i),right=bar_index[0])
box.set_bgcolor(array.get(AllBoxes, i),color.rgb(39, 43, 43))
box.set_border_color(array.get(AllBoxes, i),color.rgb(0, 0, 0))
array.push(BoxesInformation, array.get(AllBoxes, i) )
if IsDeleteBoxes
box.delete(array.get(AllBoxes, i))
Update:
Here is also the same code in case of changing it to use time instead of bar_index
.
IsDeleteBoxes = input.bool(false, "Deleted Used boxes")
string TimeFrame = input.timeframe("60")
[custom_open, custom_close, custom_high, custom_low, custom_time] = request.security(syminfo.tickerid, TimeFrame, [open, close, high, low, time])
custom_bar_index = request.security(syminfo.tickerid, TimeFrame, bar_index)
var box boxUp = na
var BoxesInformationUp = array.new_box(0)
var AllBoxesUp = box.all
if (custom_low[0]>custom_high[2])
if (custom_low[2]<custom_low[1] and custom_high>custom_high[1])
boxUp := box.new(bottom=custom_high[2], left=custom_time[2], top=custom_low[0], right=custom_time[0], bgcolor=color.rgb(43, 43, 43), extend = extend.right,xloc=xloc.bar_time, border_color=color.rgb(131, 141, 141), text=TimeFrame,text_size=size.tiny,text_color=color.rgb(207, 195, 195))
boxUp := box.new(bottom=high[2], left=custom_time[2], top=low[0], right=custom_time[0], bgcolor=color.rgb(43, 43, 43), extend = extend.right,xloc=xloc.bar_time, border_color=color.rgb(131, 141, 141))
AllBoxesUp := box.all
else
if array.size(AllBoxesUp) > 0
for i = 0 to array.size(AllBoxesUp) - 1
if (box.get_top(array.get(AllBoxesUp, i))>custom_low and not array.includes(BoxesInformationUp, array.get(AllBoxesUp, i)))
box.set_extend(array.get(AllBoxesUp, i),extend.none)
box.set_right(array.get(AllBoxesUp, i),right=custom_time[0])
box.set_bgcolor(array.get(AllBoxesUp, i),color.rgb(39, 43, 43))
box.set_border_color(array.get(AllBoxesUp, i),color.rgb(0, 0, 0))
array.push(BoxesInformationUp, array.get(AllBoxesUp, i) )
if IsDeleteBoxes
box.delete(array.get(AllBoxesUp, i))