Esempio n. 1
0
  /* (non-Javadoc)
   * @see org.eclipsetrader.ui.charts.IChartObjectFactory#createObject(org.eclipsetrader.core.charts.IDataSeries)
   */
  @Override
  public IChartObject createObject(IDataSeries source) {
    if (source == null) {
      return null;
    }

    IAdaptable[] values = source.getValues();
    Core core = Activator.getDefault() != null ? Activator.getDefault().getCore() : new Core();

    int lookback = core.cdl3OutsideLookback();
    if (values.length < lookback) {
      return null;
    }

    int startIdx = 0;
    int endIdx = values.length - 1;
    double[] inOpen = Util.getValuesForField(values, OHLCField.Open);
    double[] inHigh = Util.getValuesForField(values, OHLCField.High);
    double[] inLow = Util.getValuesForField(values, OHLCField.Low);
    double[] inClose = Util.getValuesForField(values, OHLCField.Close);

    MInteger outBegIdx = new MInteger();
    MInteger outNbElement = new MInteger();
    int[] outInteger = new int[values.length - lookback];

    core.cdl3Outside(
        startIdx, endIdx, inOpen, inHigh, inLow, inClose, outBegIdx, outNbElement, outInteger);

    return new PatternChart(getName(), values, lookback, outInteger);
  }
Esempio n. 2
0
  /* (non-Javadoc)
   * @see org.eclipsetrader.core.ats.javascript.IndicatorFunction#calculate()
   */
  @Override
  protected void calculate() {
    IAdaptable[] values = source.getValues();

    Core core = Activator.getDefault() != null ? Activator.getDefault().getCore() : new Core();

    int lookback = core.adLookback();
    if (values.length < lookback) {
      series = new NumericDataSeries(getClassName(), new Number[0], source);
      return;
    }

    int startIdx = 0;
    int endIdx = values.length - 1;
    double[] inHigh = Util.getValuesForField(values, OHLCField.High);
    double[] inLow = Util.getValuesForField(values, OHLCField.Low);
    double[] inClose = Util.getValuesForField(values, OHLCField.Close);
    double[] inVolume = Util.getValuesForField(values, OHLCField.Volume);

    MInteger outBegIdx = new MInteger();
    MInteger outNbElement = new MInteger();
    double[] outReal = new double[values.length - lookback];

    core.ad(startIdx, endIdx, inHigh, inLow, inClose, inVolume, outBegIdx, outNbElement, outReal);

    series = new NumericDataSeries(getClassName(), outReal, source);
  }