getMainMaxMinValue method

void getMainMaxMinValue(
  1. KLineEntity item,
  2. int i
)

Implementation

void getMainMaxMinValue(KLineEntity item, int i) {
  if (isLine == true) {
    mMainMaxValue = max(mMainMaxValue, item.close);
    mMainMinValue = min(mMainMinValue, item.close);
  } else {
    double maxPrice, minPrice;
    if (mainState == MainState.MA) {
      maxPrice = max(item.high, _findMaxMA(item.maValueList ?? [0]));
      minPrice = min(item.low, _findMinMA(item.maValueList ?? [0]));
    } else if (mainState == MainState.BOLL) {
      maxPrice = max(item.up ?? 0, item.high);
      minPrice = min(item.dn ?? 0, item.low);
    } else if (mainState == MainState.MAC) {
      maxPrice = max(
          item.high,
          _findMaxMA([
            item.mac_high ?? 0,
            item.mac_low ?? 0,
            item.mac_high_1 ?? 0,
            item.mac_low_1 ?? 0,
            item.top_box ?? 0,
            item.bottom_box ?? 0,
            item.moving_average ?? 0
          ]));
      minPrice = min(
          item.low,
          _findMinMA([
            item.mac_high ?? 0,
            item.mac_low ?? 0,
            item.mac_high_1 ?? 0,
            item.mac_low_1 ?? 0,
            item.top_box ?? 0,
            item.bottom_box ?? 0,
            item.moving_average ?? 0
          ]));
    } else {
      maxPrice = item.high;
      minPrice = item.low;
    }
    mMainMaxValue = max(mMainMaxValue, maxPrice);
    mMainMinValue = min(mMainMinValue, minPrice);

    if (mMainHighMaxValue < item.high) {
      mMainHighMaxValue = item.high;
      mMainMaxIndex = i;
    }
    if (mMainLowMinValue > item.low) {
      mMainLowMinValue = item.low;
      mMainMinIndex = i;
    }
  }
}