I\'m attempting to color the background on ticker ES1!
for those bars that fall within the trading session of ticker SPX
.
We can use the time(resol
You can use security
to calculate the time:
t1 = security("SPX", timeframe.period, time(timeframe.period, "0930-1600"))
bgcolor(t1 ? color.yellow : na)
UPDATE
As Bjorn Mistiaen noticed in comments, the gaps
parameter must be set to barmerge.gaps_on
:
t1 = security("SPX", timeframe.period, time(timeframe.period, "0930-1600"), gaps=barmerge.gaps_on)
bgcolor(t1 ? color.yellow : na)