signal date one day off in watchlist script

Hey guys

I am working on a watchlist that tracks signals.

I want to see the active signal (true/false), signal date, bars since current signal triggered, price when signal triggered and price change since signal triggered. Pretty standard stuff.

Now for the unstandard stuff. I am looking for signals when 65-day RSI crosses above 51 (bullish) and below 49 (bearish). This creates a gray zone so I am using the Switch function. Maybe there is an easier way and someone can enlighten me.

I reversed the switch signals to get the signal date to align with the actual signal. Now I have a problem where the signal date is one day too early, which also means there is one extra bar in the bar count and the price is based on the close the day before the signal actually triggered.

The example shows Ford (F) triggering bullish on the Watchlist on October 1st. On the price chart, RSI65 crossed above 51 on October 2nd, one day later. I tried to add an OFFSET, but it did not work.

```RSI65 = RSI(Day(PERIODAMOUNT=1), BARS=65);

bullx = RSI65 CrossesAbove 51;
bearx = RSI65 CrossesBelow 49;

bullSig = switch(bearx,bullx);
bearSig = switch(bullx,bearx);

bullBars = TIMESINCESIGNAL(bullSig, UNIT=Days);
bearBars = TIMESINCESIGNAL(bearSig, UNIT=Days) ;

bullDate = LAST(BARDATE()) - bullBars;
bearDate = LAST(BARDATE()) - bearBars;

IF(bullBars > 0, bullDate, bearDate )```

Hi Art,

You can take the extra bar off by subtracting 1 from these lines:

```bullBars = TIMESINCESIGNAL(bullSig, UNIT=Days)-1;
bearBars = TIMESINCESIGNAL(bearSig, UNIT=Days)-1;```

Thanks for the input. I don’t think that will work because the UNIT is days, not bars. And the counts do not work when I change the unit to bars.

Your suggestion triggered another idea. I added an OFFSET to the SWITCH functions to make the adjustment at the source signal and this seems to work.