Hello,

I have created special tickers that contains earnings dates for stock. Number “1” stands for earnings in these series.

So I can check if the earnings is in 5 days for example using Nz(Ref(E, 5))==1 given “E” is the ticker with the earnings.

However I would like to use conditions like E<20 days – earnings are within 20 days. Something like „barssince()” but for the future.

Is there a function fot this purpose?

Thank you,

Peter

Since you are just considering a window of time in which an event will occur, you can probably do something like this:

```
nearEarnings = Ref(Sum(E,20), 20) > 0;
```

Obviously 20 could be replaced with a variable. Also, this function will return `true`

if E is true in the **next** 20 bars (excluding today), but `false`

if E is **only** true on the current bar. To consider the current bar and the next 19 bars (i.e. 20 days **including** today), you would change the above to:

```
nearEarnings = Ref(Sum(E,20), 19) > 0;
```