public int getRequiredHistorySize() { if (this.function == Function.EMA) { Core core = new Core(); int lookback = core.emaLookback(day); return ((lookback + 1) << 2); } else if (function == Function.RSI) { Core core = new Core(); int lookback = core.rsiLookback(day); return ((lookback + 1) << 2); } else if (this.function == Function.MFI) { Core core = new Core(); int lookback = core.mfiLookback(day); return ((lookback + 1) << 2); } else if (this.function == Function.MACD) { Core core = new Core(); int lookback = core.macdFixLookback(day); return ((lookback + 1) << 2); } else if (this.function == Function.MACDSignal) { Core core = new Core(); int lookback = core.macdFixLookback(day); return ((lookback + 1) << 2); } else if (this.function == Function.MACDHist) { Core core = new Core(); int lookback = core.macdFixLookback(day); return ((lookback + 1) << 2); } else { return day; } }
public static Double createRSI(List<Double> values, int period) { if (period <= 0) { throw new IllegalArgumentException("period must be greater than 0"); } final int size = values.size(); final Core core = new Core(); final int allocationSize = size - core.rsiLookback(period); if (allocationSize <= 0) { return null; } final double[] output = new double[allocationSize]; final MInteger outBegIdx = new MInteger(); final MInteger outNbElement = new MInteger(); double[] _values = ArrayUtils.toPrimitive(values.toArray(new Double[0])); core.rsi(0, values.size() - 1, _values, period, outBegIdx, outNbElement, output); return output[outNbElement.value - 1]; }