last buy or sell signal value

#3
By any chance do you know how to find out not the last signal value, but just what was previous signal - long or short?

I was thinking about using something like:
if(Ref(LongPositionCount,-1)=1,sell short,do nothing).

but it doesn't work.