Exclude a signal over a date range

Anyone know if it is possible to stop a signal from firing in a script if the signal falls within a certain date range? e.g. want to find every time LOW() is less than lower Bollinger Band, except between the dates 01-01-2015 and 31-12-2016.

//Script concept

Signal = LOW() < BB(BARS=20, DEFAULT=LowerLine);

RangeStart = BARDATE(01-01-2015);

RangeEnd = BARDATE(31-12-2016);

Signal and ((BARDATE(CLOSE()) < RangeStart) or (BARDATE(CLOSE()) > RangeEnd));

Any alternative ideas or methods welcomed.

Many thanks, Dean M

 

Hi Dean,

For entire years you can use the YEARNUM() function, so in your example you could use the following:

V1 = LOW() < BB(DEFAULT=LowerLine, BARS=20);
V1 and (YEARNUM() < 2015 or YEARNUM() > 2016)

For specific dates you can use the BARDATE() function, but you would need to know the value which we specify for each date. The best way to see this value for each bar is to add a custom label to your tool tip label - see video here:

How to Add Custom Tooltip Labels

The function to add to the label is simply BARDATE(), and then when you mouse over each bar it will give you the value, eg June 27th 2016 was 42,548:

 

Capture

 

This can then be used in a formula as per this example to exclude results between that date and February 7th 2017 (42,773):

V1 = LOW() < BB(DEFAULT=LowerLine, BARS=20);
V1 and (BARDATE() < 42548 or BARDATE() > 42773)

 

 

Darren, thank you so much, what you have provided is absolutely perfect! Really appreciate the super fast response too.

Many thanks, Dean M

Instead of having to find the bardate value in a script you can now use the STRDATE() function to select the date from a calendar pop up:

https://help.optuma.com/kb/faq.php?id=922

Darren, thank you for the follow-up as a result of the introduction of new functions with the latest release of Optuma. That is super effective in helping me keep my knowledge current. Really appreciated. Cheers, Dean