/** * * This is a http://en.wikipedia.org/wiki/MACD * * * @author Freeman Lo * @version 0.0.1 Build 1 April 1, 2014. * Limitations - i would like to add a Date associate to this next time i do this application. */ import java.util.ArrayList; import java.util.Collections; public class ProcessMACD { ArrayList sArrList = new ArrayList (); ArrayList macd = new ArrayList (); ArrayList ema12 = new ArrayList (); ArrayList ema26 = new ArrayList (); public ProcessMACD (ArrayList sArrList) { this.sArrList = sArrList; } public void setEMAValues(ArrayList ema12, ArrayList ema26) { this.ema12 = ema12; this.ema26 = ema26; } public void computeMACD() { double macd = 0.00; for ( int item = 0; item < this.ema26.size(); item++ ) { // starts with 0, so 12 is actually 13th place // stupid math was complicated since i had to manually count // the stupid slots macd = this.ema12.get(item+14) - this.ema26.get(item); this.macd.add(macd); } } public void printMACDValues() { // reverse the stupid list to show most recent on top Collections.reverse(this.macd); for (int item = 0; item < macd.size(); item++ ) { System.out.println("The MACD values for this is: " + this.macd.get(item) ); } } }