DEFPARAM DrawOnLastBarOnly = true
ONCE UKstart = 090000
ONCE UKend = 180000
ONCE USstart = 150000
ONCE USend = 230000
ONCE UKhh = 0
ONCE UKll = 9999999
ONCE UShh = 0
ONCE USll = 9999999
TimeRef = OpenTime
IF TimeRef = 000000 OR ((TimeRef > 000000) AND (TimeRef < TimeRef[1])) THEN
UKhh = 0
UKll = 9999999
UShh = 0
USll = 9999999
ENDIF
//
UKsession = TimeRef >= UKstart AND TimeRef <= UKend
USsession = TimeRef >= USstart AND TimeRef <= USend
//
backgroundcolor(255,255,255,255) //WHITE background (default)
IF TimeRef >= UKstart AND TimeRef < USstart AND TimeRef <= UKend THEN
backgroundcolor(176,226,255,80) //CYAN background (overlapping sessions)
ELSIF TimeRef >= UKstart AND TimeRef <= UKend THEN
backgroundcolor(0,128,0,40) //GREEN background (UK session)
ELSIF TimeRef >= USstart AND TimeRef > UKend AND TimeRef <= USend THEN
backgroundcolor(255,187,255,40) //PINK background (US session)
ENDIF
//
IF UKsession THEN
UKhh = max(UKhh,high)
UKll = min(UKll,low)
UKgap = UKhh - UKll
ENDIF
IF USsession THEN
UShh = max(UShh,high)
USll = min(USll,low)
USgap = UShh - USll
ENDIF
//
Offset = max(UKhh,UShh)
Rng = average[100,0](range)
DrawText("UK #UKgap#",BarIndex,Offset + rng) coloured(0,0,0,255)
DrawText("US #USgap#",BarIndex,Offset + rng * 2) coloured(0,0,0,255)
RETURN