Similar to COUNTIFS, except LASTIFS returns a vector containing the number of days since the last time the specified condition evaluated to TRUE. The count is reset to zero each time the condition evaluates to TRUE.
LASTIFS(condition, reset condition)
SET SMA = SMA(CLOSE,14)
SET SELL = CROSSOVER(CLOSE,SMA)
LASTIFS(CLOSE < REF(CLOSE, 1))
//With reset version
LASTIFS(CLOSE < REF(CLOSE, 1),SELL)
The script returns a vector that increases in value for each bar where the closing price was not less than the previous closing price. When the condition evaluates to TRUE, meaning the closing price was less than the previous closing price. On the reset version, the count resets on the sell condition.