I have used machine learning before for edge detection, image identification problem solving and other tasks before. If enough data exists a script can be generated to predict when one should buy and one should sell. Neural networks are ultimately the best candidate at first glance. But depending on how accurate you want it anfis could be used to achieve the task.