Tradestation.com is widely used for rule based stock trading.
This book also included the source code of how to write a stock trading system:
http://www.amazon.com/Professional-Stock-Trading-System-Automation/dp/0971853649/ref=sr_1_5?ie=UTF8&qid=1287345018&sr=8-5