I want alerts (buy and sell both) at the opening of the current candle if the stochastic crossover happened at the close of the previous candle.
If you want to set the alert at the crossover, then,
BUY,
SET A= Ref(close,1)
SET B = SOPK(9, 3, 9, SIMPLE) OR SOPD(9, 3, 9, SIMPLE)
CROSSOVER(A,B)
SELL,
SET A= Ref(close,1)
SET B = SOPK(9, 3, 9, SIMPLE) OR SOPD(9, 3, 9, SIMPLE)
CROSSOVER(B,A)