script times {
input coverHLOnly = yes;
input minutes = 360;
input begin = 1800;
input end = 0259;
def sec1 = SecondsFromTime(begin);
def sec2 = SecondsFromTime(end);
#1er cuadro amarillo el de Asia
def isTime1 = (sec1 > 0 and sec1[1] <= 0) or (sec1 < sec1[1] and sec1 >= 0);
#2do Cuadro Azul el de Europa
def isTime2 = (sec2 > 0 and sec2[1] <= 0) or (sec2 < sec2[1] and sec2 > 0);
def topaint = CompoundValue(1, if isTime1 then 1 else if isTime2 then 0 else topaint[1], 0);
def dayh = if toPaint[1] == 0 and toPaint == 1
then high
else if toPaint == 1
then Max(high, dayh[1])
else 0;
def dayhi = if toPaint[1] == 1 and toPaint == 0
then dayh[1]
else dayhi[1];
def dayl = if toPaint[1] == 0 and toPaint == 1
then low
else if toPaint == 1
then Min(low, dayl[1]) else 0 ;
def daylo = if toPaint[1] == 1 and toPaint == 0
then dayl[1]
else daylo[1];
plot up = if GetDay() <= GetLastDay() and toPaint
then if coverHLOnly == no
then Double.POSITIVE_INFINITY
else dayhi[-minutes / (GetAggregationPeriod() / 60000)]
else Double.NaN;
plot down = if GetDay() <= GetLastDay() and toPaint
then if coverHLOnly == no
then Double.NEGATIVE_INFINITY
else daylo[-minutes / (GetAggregationPeriod() / 60000)]
else Double.NaN;
}
input begin1 = 1745;
input end1 = 0300;
input minutes1 = 560;
def up1 = times(minutes = minutes1, begin = begin1, end = end1);
def down1 = times(minutes = minutes1, begin = begin1, end = end1).down;
AddCloud(up1, down1, createColor(255,185,50), createColor(255,185,50));
input begin2 = 0259;
input end2 = 0930;
input minutes2 = 510;
def up2 = times(minutes = minutes2, begin = begin2, end = end2);
def down2 = times(minutes = minutes2, begin = begin2, end = end2).down;
AddCloud(up2, down2, createColor(116,189,232), createColor(116,189,232));
input showlabels = yes;
addlabel(showlabels, "Tokyo", color.yellow);
addlabel(showlabels, "Europe", color.blue);