| | |
| | | // 1. 计算200日EMA(趋势过滤) |
| | | List<BigDecimal> trendEma = EMACalculator.calculateEMA(close1DPrices, trendPeriod, true); |
| | | BigDecimal latestTrendEma = trendEma.get(trendEma.size() - 1); |
| | | BigDecimal latestPrice = closePrices.get(closePrices.size() - 1); |
| | | BigDecimal latestPrice = closePrices.get(0); |
| | | log.info( "200日EMA:{},{}", latestTrendEma, latestPrice); |
| | | |
| | | // 2. 价格必须位于200日EMA上方(多头趋势确认) |
| | | boolean isAboveTrend = latestPrice.compareTo(latestTrendEma) > 0; |
| | |
| | | // 1. 计算200日EMA(趋势过滤) |
| | | List<BigDecimal> trendEma = EMACalculator.calculateEMA(close1DPrices, trendPeriod, true); |
| | | BigDecimal latestTrendEma = trendEma.get(trendEma.size() - 1); |
| | | BigDecimal latestPrice = closePrices.get(closePrices.size() - 1); |
| | | BigDecimal latestPrice = closePrices.get(0); |
| | | |
| | | log.info( "200日EMA:{},{}", latestTrendEma, latestPrice); |
| | | |
| | | // 2. 价格必须位于200日EMA下方(空头趋势确认) |
| | | boolean isBelowTrend = latestPrice.compareTo(latestTrendEma) < 0; |
| | |
| | | return false; |
| | | } |
| | | |
| | | PriceData latest = macdData.get(macdData.size() - 1); |
| | | PriceData previous = macdData.get(macdData.size() - 2); |
| | | PriceData latest = macdData.get(0); |
| | | PriceData previous = macdData.get(1); |
| | | |
| | | // 金叉判断:DIF从下往上穿过DEA |
| | | return previous.getDif().compareTo(previous.getDea()) < 0 && |
| | |
| | | return false; |
| | | } |
| | | |
| | | PriceData latest = macdData.get(macdData.size() - 1); |
| | | PriceData previous = macdData.get(macdData.size() - 2); |
| | | PriceData latest = macdData.get(0); |
| | | PriceData previous = macdData.get(1); |
| | | |
| | | // 死叉判断:DIF从上往下穿过DEA |
| | | return previous.getDif().compareTo(previous.getDea()) > 0 && |
| | |
| | | return false; |
| | | } |
| | | |
| | | PriceData latest = macdData.get(macdData.size() - 1); |
| | | PriceData previous = macdData.get(macdData.size() - 2); |
| | | PriceData latest = macdData.get(0); |
| | | PriceData previous = macdData.get(1); |
| | | |
| | | // 柱状线由负转正:前一根为负,当前为正 |
| | | return previous.getMacdHist().compareTo(BigDecimal.ZERO) <= 0 && |
| | |
| | | return false; |
| | | } |
| | | |
| | | PriceData latest = macdData.get(macdData.size() - 1); |
| | | PriceData previous = macdData.get(macdData.size() - 2); |
| | | PriceData latest = macdData.get(0); |
| | | PriceData previous = macdData.get(1); |
| | | |
| | | // 柱状线由正转负:前一根为正,当前为负 |
| | | return previous.getMacdHist().compareTo(BigDecimal.ZERO) >= 0 && |