calcBOLL static method

void calcBOLL(
  1. List<KLineEntity> dataList,
  2. int n,
  3. int k
)

Implementation

static void calcBOLL(List<KLineEntity> dataList, int n, int k) {
  _calcBOLLMA(n, dataList);
  for (int i = 0; i < dataList.length; i++) {
    KLineEntity entity = dataList[i];
    if (i >= n) {
      double md = 0;
      for (int j = i - n + 1; j <= i; j++) {
        double c = dataList[j].close;
        double m = entity.BOLLMA!;
        double value = c - m;
        md += value * value;
      }
      md = md / (n - 1);
      md = sqrt(md);
      entity.mb = entity.BOLLMA!;
      entity.up = entity.mb! + k * md;
      entity.dn = entity.mb! - k * md;
    }
  }
}