Avoiding whipsaw action

Does anybody have a reliable algorithm for detecting whipsaw activity? I’m sure that many strategies would benefit from having a block of logic that identifies whipsaw activity, so I figure this is probably a common problem algo traders are facing.

I found the following relevant articles.