If I've understood correctly, this is hard to do efficiently because the choice depends upon the past. It's not elegant but this code gives the output you require,
library("xts")
close <- c(0, -0.5, -0.75, -1, -0.75, -1.5, -2, -2.5, -3, -3.5, -3, -2.5, -2, -1, 0, 1, 1.5, 2, 2.5, 3, 2.5, 2, 0)
data <- xts(close, Sys.Date()-23:1)
colnames(data) <- "close"
sig.buy <- c(F,F,F)
sig.short <- c(F,F,F)
for(i in 1:length(data))
{
if(data$close[i] <= -1) sig.buy[1] <- T
if(data$close[i] <= -2) sig.buy[2] <- T
if(data$close[i] <= -3) sig.buy[3] <- T
if(sig.buy[1] && data$close[i] >= 0) sig.buy[1] <- F
if(sig.buy[2] && data$close[i] >= 0) sig.buy[2] <- F
if(sig.buy[3] && data$close[i] >= 0) sig.buy[3] <- F
if(data$close[i] >= 1) sig.short[1] <- T
if(data$close[i] >= 2) sig.short[2] <- T
if(data$close[i] >= 3) sig.short[3] <- T
if(sig.short[1] && data$close[i] <= 0) sig.short[1] <- F
if(sig.short[2] && data$close[i] <= 0) sig.short[2] <- F
if(sig.short[3] && data$close[i] <= 0) sig.short[3] <- F
data$trade[i] <- sum(sig.buy) - sum(sig.short)
}