How do I combine an if condition/statement with the logical operators and/or?

To include “and” in the function use the “&” sign as such:

if(condition1 & condition2, value1, value2)

which can be expanded on as:

if(condition1 and condition2, if_TRUE_return_this , if_FALSE_return_this)

For example:

if(sek>7 & sek<8, sek, 0)

which returns the values of the series on days when the series is between 7 and 8. For all other observations, the value of the series will be 0.

To include “or” in the function use the “|” sign as such:

if(condition1|condition2, value1, value2)

which can be expanded on as:

if(condition1 OR condition2, , if_TRUE_return_this , if_FALSE_return_this)

For example:

if(sek>7 | sek<9, sek, 0)

which returns the values of the series on days when the series is above 7 or below 9. For all other observations, the value of the series will be 0.

For more information:

How do I create an if condition / statement?

The Macrobond formula language

Formula