@Test public void passesAMarketWithTheDownwardChangesAsClosePriceToTheUpMovingAverage() { cut.indicate(marketPrice(53)); cut.indicate(marketPrice(21)); cut.indicate(marketPrice(10)); cut.indicate(marketPrice(10)); final InOrder downMaValues = inOrder(downMa); downMaValues.verify(downMa).indicate(marketPrice(32)); downMaValues.verify(downMa).indicate(marketPrice(11)); downMaValues.verify(downMa).indicate(marketPrice(0)); downMaValues.verifyNoMoreInteractions(); verify(upMa, times(3)).indicate(marketPrice(0)); verifyNoMoreInteractions(upMa); }
@Override public Optional<Ratio> indicate(final MP price) { final Price lastPrice = this.lastPrice; final Price currentPrice = price.getClose(); this.lastPrice = price.getClose(); if (lastPrice == null) { return Optional.empty(); } if (lastPrice.equals(currentPrice)) { return rsi(noChange, noChange); } if (lastPrice.isLessThan(currentPrice)) { return rsi(new BasicMarketData(currentPrice.minus(lastPrice)), noChange); } else { return rsi(noChange, new BasicMarketData(lastPrice.minus(currentPrice))); } }
RelativeStrengthIndex implements Indicator<Ratio, MP> { @Override public Optional<Ratio> indicate(final MP price) { final Price lastPrice = this.lastPrice; final Price currentPrice = price.getClose(); this.lastPrice = price.getClose(); if (lastPrice == null) { return Optional.empty(); } if (lastPrice.equals(currentPrice)) { return rsi(noChange, noChange); } if (lastPrice.isLessThan(currentPrice)) { return rsi(new BasicMarketData(currentPrice.minus(lastPrice)), noChange); } else { return rsi(noChange, new BasicMarketData(lastPrice.minus(currentPrice))); } } }
RelativeStrengthIndex implements Indicator<Ratio, MP> { @Override public Optional<Ratio> indicate(final MP price) { final Price lastPrice = this.lastPrice; final Price currentPrice = price.getClose(); this.lastPrice = price.getClose(); if (lastPrice == null) { return Optional.empty(); } if (lastPrice.equals(currentPrice)) { return rsi(noChange, noChange); } if (lastPrice.isLessThan(currentPrice)) { return rsi(new BasicMarketData(currentPrice.minus(lastPrice)), noChange); } else { return rsi(noChange, new BasicMarketData(lastPrice.minus(currentPrice))); } } RelativeStrengthIndex(final int aggregationCount);  RelativeStrengthIndex(final Indicator<Price, MarketData> upMa,
            final Indicator<Price, MarketData> downMa); }
RelativeStrengthIndex implements Indicator<Ratio, MP> { @Override public Optional<Ratio> indicate(final MP price) { final Price lastPrice = this.lastPrice; final Price currentPrice = price.getClose(); this.lastPrice = price.getClose(); if (lastPrice == null) { return Optional.empty(); } if (lastPrice.equals(currentPrice)) { return rsi(noChange, noChange); } if (lastPrice.isLessThan(currentPrice)) { return rsi(new BasicMarketData(currentPrice.minus(lastPrice)), noChange); } else { return rsi(noChange, new BasicMarketData(lastPrice.minus(currentPrice))); } } RelativeStrengthIndex(final int aggregationCount);  RelativeStrengthIndex(final Indicator<Price, MarketData> upMa,
            final Indicator<Price, MarketData> downMa); @Override Optional<Ratio> indicate(final MP price); }
RelativeStrengthIndex implements Indicator<Ratio, MP> { @Override public Optional<Ratio> indicate(final MP price) { final Price lastPrice = this.lastPrice; final Price currentPrice = price.getClose(); this.lastPrice = price.getClose(); if (lastPrice == null) { return Optional.empty(); } if (lastPrice.equals(currentPrice)) { return rsi(noChange, noChange); } if (lastPrice.isLessThan(currentPrice)) { return rsi(new BasicMarketData(currentPrice.minus(lastPrice)), noChange); } else { return rsi(noChange, new BasicMarketData(lastPrice.minus(currentPrice))); } } RelativeStrengthIndex(final int aggregationCount);  RelativeStrengthIndex(final Indicator<Price, MarketData> upMa,
            final Indicator<Price, MarketData> downMa); @Override Optional<Ratio> indicate(final MP price);  }