@Test public void shouldCalculatePivotPointsCorrectlyForBearishCandles() { final CandleStick input = new CandleStick(new Price(25182), new Price(25683), new Price(22381), new Price(23869)); final PriceLevels pivotPoints = cut.indicate(input).get(); assertThat(pivotPoints.count()).isEqualTo(5); assertThat(pivotPoints.get(0)).isEqualTo(new Price(20675)); assertThat(pivotPoints.get(1)).isEqualTo(new Price(22271)); assertThat(pivotPoints.get(2)).isEqualTo(new Price(23977)); assertThat(pivotPoints.get(3)).isEqualTo(new Price(25573)); assertThat(pivotPoints.get(4)).isEqualTo(new Price(27279)); }
@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);  }