// Bearish Divergence
Cond1=( Close >= HHV( Close, 21 ) AND RSI(14) < HHV( RSI(14), 21 ));
Cond2=RSI(14) <= LLV( RSI(14), 21) AND Close
> LLV(Close,21);
// Bullish Divergence
Cond3= RSI(14) >= HHV( RSI(14), 21 ) AND
Close < HHV( Close, 21 );
Cond4= Close <= LLV( Close, 21 ) AND RSI(14) > LLV( RSI(14), 21 );
Buy = Cond3
OR Cond4;
Sell = Cond1
OR Cond2
Cheers
Prashanth