Shading a Timer Period


I want shade a time period with a script. For example the time period between 08/15/2016 to 11/04/2016.

I have created the following four scripts:

MONTHNUM()==8 and DAYNUM()>14 and YEARNUM() == 2016
MONTHNUM()==9 and YEARNUM() == 2016
MONTHNUM()==10 and YEARNUM() == 2016
MONTHNUM()==11 and DAYNUM()<5 and YEARNUM() == 2016

These four script using the Show View tool and moved into the chart window would do the job, see my screen shot.

time period

BUT is there a way to combine the four scripts into one script or creating a new script that shades the time period between 08/15/2016 to 11/04/2016?

I was not successful in combining the four scripts into one, nothing worked.

Another question, what if the time period that should be shaded spans over two years, e.g. from 10/13/2017 to 01/18/2018?


Hi Thomas,

You can use the STRDATE() function to specify the dates from a calendar:

For your example, set the variables for when the bardate is within those dates:

Start = BARDATE()>=STRDATE(DATE=2016-08-15);
End = BARDATE()<=STRDATE(DATE=2016-11-04);
Start and End


Hi Darren,

many many thank. Your script is really smart.