Based on the description in Murphy, Tech. Analysis of Financial Markets. Wikipeadia also has a good description: en.wikipedia.org/wiki/McClellan_oscillator Without warranty - please trade based on your own analysis and let me know if you find any errors in the script.