// 高值计算,计算date日期前count天最高价格 public float GetHigh(int count, String date) { if (historyData.size() == 0) return 0.0f; float value = 0.0f; int iE = ANLUtils.indexDayKBeforeDate(historyData, date); int iB = iE - count + 1; if (iB < 0) iB = 0; for (int i = iB; i <= iE; i++) { ANLStockDayKData cANLDayKData = historyData.get(i); if (cANLDayKData.high >= value) { value = cANLDayKData.high; } // ANLLog.outputConsole("%s %.2f\n", cANLDayKData.date, cANLDayKData.close); } return value; }
// 均线计算,计算date日期前count天均线价格 public float GetMA(int count, String date) { if (historyData.size() == 0) return 0.0f; float value = 0.0f; int iE = ANLUtils.indexDayKBeforeDate(historyData, date); int iB = iE - count + 1; if (iB < 0) iB = 0; float sum = 0.0f; int sumcnt = 0; for (int i = iB; i <= iE; i++) { ANLStockDayKData cANLDayKData = historyData.get(i); sum = sum + cANLDayKData.close; sumcnt++; // ANLLog.outputConsole("%s %.2f\n", cANLDayKData.date, cANLDayKData.close); } value = sum / sumcnt; return value; }