My first indi script and it calculates properly but it doesn't plot past 2 days prior. So basically plots the current day but after that not plotting anymore correctly. Any help here? Many thnks
//@version=5
indicator(title="Divergence", overlay=true)
tf_short = input(title="Timeframe",defval='15')
sym1_short = input(title="Symbol1", defval="eurusd"), res1 = tf_short, source11 = open, source12 = close, source13 = high, source14 = low
sym2_short = input(title="Symbol2", defval="gbpusd"), res2 = tf_short, source21 = open, source22 = close
open_price1 = request.security(sym1_short, res1, source11)
close_price1 = request.security(sym1_short, res1, source12)
high_price1 = request.security(sym1_short, res1, source13)
low_price1 = request.security(sym1_short, res1, source14)
open_price2 = request.security(sym2_short, res2, source21)
close_price2 = request.security(sym2_short, res2, source22)
down_bar2 = close_price2 < open_price2
up_bar2 = close_price2 > open_price2
up_bar1 = close_price1 > open_price1
down_bar1 = close_price1 < open_price1
up_bar = up_bar1 and down_bar2
down_bar = down_bar1 and up_bar2
color_up = color.new(color.green, transp = 80)
color_down = color.new(color.red, transp = 80)
box_offset_x = (timeframe.period == "5") ? -2 : (timeframe.period == "15") ? -1 : na
box_offset_y = (timeframe.period == "5") ? -1 : (timeframe.period == "15") ? 1 : na
line_offset_x = (timeframe.period == "5") ? -2 : (timeframe.period == "15") ? -2 : na
line_offset_y = (timeframe.period == "5") ? +3 : (timeframe.period == "15") ? +6 : na
if up_bar
box.new(bar_index+box_offset_x, high_price1,bar_index+box_offset_y, low_price1, border_color=na , bgcolor=color_up )
line.new(bar_index+line_offset_x, high_price1, bar_index+line_offset_y, high_price1 , color=color_up)
line.new(bar_index+line_offset_x, low_price1, bar_index+line_offset_y, low_price1 , color=color_up)
if down_bar
box.new(bar_index+box_offset_x, high_price1,bar_index+box_offset_y, low_price1, border_color=na , bgcolor=color_down )
line.new(bar_index+line_offset_x, high_price1, bar_index+line_offset_y, high_price1 , color=color_down)
line.new(bar_index+line_offset_x, low_price1, bar_index+line_offset_y, low_price1 , color=color_down)