@Test public void shouldCalculatePivotPointsCorrectlyForBullishCandles() { final CandleStick input = new CandleStick(new Price(129183), new Price(130273), new Price(129007), new Price(129735)); final PriceLevels pivotPoints = cut.indicate(input).get(); assertThat(pivotPoints.count()).isEqualTo(5); assertThat(pivotPoints.get(0)).isEqualTo(new Price(128405)); assertThat(pivotPoints.get(1)).isEqualTo(new Price(129069)); assertThat(pivotPoints.get(2)).isEqualTo(new Price(129671)); assertThat(pivotPoints.get(3)).isEqualTo(new Price(130335)); assertThat(pivotPoints.get(4)).isEqualTo(new Price(130937)); }
@Override public Optional<PriceLevels> indicate(final C candle) { final long high = candle.getHigh().asPipette(); final long low = candle.getLow().asPipette(); final long close = candle.getClose().asPipette(); final long p = (high + low + close) / 3; final long r1 = (2 * p) - low; final long r2 = p + (high - low); final long s1 = (2 * p) - high; final long s2 = p - (high - low); return Optional.of(new PriceLevels(new Price(s2), new Price(s1), new Price(p), new Price(r1), new Price(r2))); }
PivotPointsIndicator implements Indicator<PriceLevels, C> { @Override public Optional<PriceLevels> indicate(final C candle) { final long high = candle.getHigh().asPipette(); final long low = candle.getLow().asPipette(); final long close = candle.getClose().asPipette(); final long p = (high + low + close) / 3; final long r1 = (2 * p) - low; final long r2 = p + (high - low); final long s1 = (2 * p) - high; final long s2 = p - (high - low); return Optional.of(new PriceLevels(new Price(s2), new Price(s1), new Price(p), new Price(r1), new Price(r2))); } }
PivotPointsIndicator implements Indicator<PriceLevels, C> { @Override public Optional<PriceLevels> indicate(final C candle) { final long high = candle.getHigh().asPipette(); final long low = candle.getLow().asPipette(); final long close = candle.getClose().asPipette(); final long p = (high + low + close) / 3; final long r1 = (2 * p) - low; final long r2 = p + (high - low); final long s1 = (2 * p) - high; final long s2 = p - (high - low); return Optional.of(new PriceLevels(new Price(s2), new Price(s1), new Price(p), new Price(r1), new Price(r2))); }  }
PivotPointsIndicator implements Indicator<PriceLevels, C> { @Override public Optional<PriceLevels> indicate(final C candle) { final long high = candle.getHigh().asPipette(); final long low = candle.getLow().asPipette(); final long close = candle.getClose().asPipette(); final long p = (high + low + close) / 3; final long r1 = (2 * p) - low; final long r2 = p + (high - low); final long s1 = (2 * p) - high; final long s2 = p - (high - low); return Optional.of(new PriceLevels(new Price(s2), new Price(s1), new Price(p), new Price(r1), new Price(r2))); }  @Override Optional<PriceLevels> indicate(final C candle); }
PivotPointsIndicator implements Indicator<PriceLevels, C> { @Override public Optional<PriceLevels> indicate(final C candle) { final long high = candle.getHigh().asPipette(); final long low = candle.getLow().asPipette(); final long close = candle.getClose().asPipette(); final long p = (high + low + close) / 3; final long r1 = (2 * p) - low; final long r2 = p + (high - low); final long s1 = (2 * p) - high; final long s2 = p - (high - low); return Optional.of(new PriceLevels(new Price(s2), new Price(s1), new Price(p), new Price(r1), new Price(r2))); }  @Override Optional<PriceLevels> indicate(final C candle);  }