@Test public void noResultForFirst60DataPoints() throws IOException { for (int i = 0; i < 60; i++) { assertThat(cut.indicate(testData.get(i).marketData)).isEmpty(); } for (int i = 60; i < 70; i++) { assertThat(cut.indicate(testData.get(i).marketData)).isPresent(); } }
@Override public Optional<Price> indicate(final C marketPrice) { if (currentPeriode == 0) { this.trend = UP; this.extremePoint = marketPrice.getHigh().asDouble(); this.sar = marketPrice.getLow().asDouble(); this.accelerationFactor = increasment; } final double delta = abs(extremePoint - sar) * accelerationFactor; sar = trend == UP ? sar + delta : sar - delta; if (shouldTurn(marketPrice)) { turnSAR(marketPrice); } else { updateValues(marketPrice); } if (currentPeriode < SETUP_PERIODS) { currentPeriode++; return Optional.empty(); } else { return Optional.of(new Price(sar)); } }
ParabolicStopAndReverse implements Indicator<Price, C> { @Override public Optional<Price> indicate(final C marketPrice) { if (currentPeriode == 0) { this.trend = UP; this.extremePoint = marketPrice.getHigh().asDouble(); this.sar = marketPrice.getLow().asDouble(); this.accelerationFactor = increasment; } final double delta = abs(extremePoint - sar) * accelerationFactor; sar = trend == UP ? sar + delta : sar - delta; if (shouldTurn(marketPrice)) { turnSAR(marketPrice); } else { updateValues(marketPrice); } if (currentPeriode < SETUP_PERIODS) { currentPeriode++; return Optional.empty(); } else { return Optional.of(new Price(sar)); } } }
ParabolicStopAndReverse implements Indicator<Price, C> { @Override public Optional<Price> indicate(final C marketPrice) { if (currentPeriode == 0) { this.trend = UP; this.extremePoint = marketPrice.getHigh().asDouble(); this.sar = marketPrice.getLow().asDouble(); this.accelerationFactor = increasment; } final double delta = abs(extremePoint - sar) * accelerationFactor; sar = trend == UP ? sar + delta : sar - delta; if (shouldTurn(marketPrice)) { turnSAR(marketPrice); } else { updateValues(marketPrice); } if (currentPeriode < SETUP_PERIODS) { currentPeriode++; return Optional.empty(); } else { return Optional.of(new Price(sar)); } } ParabolicStopAndReverse(final Ratio accelerationFactorIncreasment, final Ratio maximalAcceleration); }
ParabolicStopAndReverse implements Indicator<Price, C> { @Override public Optional<Price> indicate(final C marketPrice) { if (currentPeriode == 0) { this.trend = UP; this.extremePoint = marketPrice.getHigh().asDouble(); this.sar = marketPrice.getLow().asDouble(); this.accelerationFactor = increasment; } final double delta = abs(extremePoint - sar) * accelerationFactor; sar = trend == UP ? sar + delta : sar - delta; if (shouldTurn(marketPrice)) { turnSAR(marketPrice); } else { updateValues(marketPrice); } if (currentPeriode < SETUP_PERIODS) { currentPeriode++; return Optional.empty(); } else { return Optional.of(new Price(sar)); } } ParabolicStopAndReverse(final Ratio accelerationFactorIncreasment, final Ratio maximalAcceleration); @Override Optional<Price> indicate(final C marketPrice); }
ParabolicStopAndReverse implements Indicator<Price, C> { @Override public Optional<Price> indicate(final C marketPrice) { if (currentPeriode == 0) { this.trend = UP; this.extremePoint = marketPrice.getHigh().asDouble(); this.sar = marketPrice.getLow().asDouble(); this.accelerationFactor = increasment; } final double delta = abs(extremePoint - sar) * accelerationFactor; sar = trend == UP ? sar + delta : sar - delta; if (shouldTurn(marketPrice)) { turnSAR(marketPrice); } else { updateValues(marketPrice); } if (currentPeriode < SETUP_PERIODS) { currentPeriode++; return Optional.empty(); } else { return Optional.of(new Price(sar)); } } ParabolicStopAndReverse(final Ratio accelerationFactorIncreasment, final Ratio maximalAcceleration); @Override Optional<Price> indicate(final C marketPrice);  }