コード例 #1
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
 @Override
 public String getLabel() {
   return properties.getLabel()
       + " ("
       + properties.getPeriod()
       + ", "
       + properties.getPeriodK()
       + ", "
       + properties.getPeriodD()
       + ")";
 }
コード例 #2
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
  @Override
  public void paint(Graphics2D g, ChartFrame cf, Rectangle bounds) {
    Dataset stoD = visibleDataset(cf, properties.getSF() ? FASTD : SLOWD);
    Dataset stoK = visibleDataset(cf, properties.getSF() ? FASTK : SLOWK);

    if (stoD != null && stoK != null) {
      if (maximized) {
        Range range = getRange(cf);

        DefaultPainter.line(
            g, cf, range, bounds, stoD, properties.getColorD(), properties.getStrokeD());
        DefaultPainter.line(
            g, cf, range, bounds, stoK, properties.getColorK(), properties.getStrokeK());
      }
    }
  }
コード例 #3
0
ファイル: HTTrendLine.java プロジェクト: viorelgheba/chartsy
 @Override
 public void paint(Graphics2D g, ChartFrame cf, Rectangle bounds) {
   Dataset dataset = visibleDataset(cf, HASHKEY);
   if (dataset != null) {
     if (maximized) {
       Range range = getRange(cf);
       DefaultPainter.line(
           g,
           cf,
           range,
           bounds,
           dataset,
           properties.getColor(),
           properties.getStroke()); // paint line
     }
   }
 }
コード例 #4
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
  @Override
  public double[] getValues(ChartFrame cf, int i) {
    Dataset stoD = visibleDataset(cf, properties.getSF() ? FASTD : SLOWD);
    Dataset stoK = visibleDataset(cf, properties.getSF() ? FASTK : SLOWK);

    if (stoD != null && stoK != null) return new double[] {stoD.getCloseAt(i), stoK.getCloseAt(i)};
    return new double[] {};
  }
コード例 #5
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
  @Override
  public LinkedHashMap getHTML(ChartFrame cf, int i) {
    LinkedHashMap ht = new LinkedHashMap();

    DecimalFormat df = new DecimalFormat("#,##0.00");
    double[] values = getValues(cf, i);
    String[] labels = {"%D:", "%K:"};

    ht.put((properties.getSF() ? "Fast" : "Slow") + getLabel(), " ");
    if (values.length > 0) {
      Color[] colors = getColors();
      for (int j = 0; j < values.length; j++) {
        ht.put(getFontHTML(colors[j], labels[j]), getFontHTML(colors[j], df.format(values[j])));
      }
    }

    return ht;
  }
コード例 #6
0
ファイル: HTTrendLine.java プロジェクト: viorelgheba/chartsy
 @Override
 public String getLabel() {
   return properties.getLabel();
 }
コード例 #7
0
ファイル: HTTrendLine.java プロジェクト: viorelgheba/chartsy
 @Override
 public boolean getMarkerVisibility() {
   return properties.getMarker();
 }
コード例 #8
0
ファイル: HTTrendLine.java プロジェクト: viorelgheba/chartsy
 @Override
 public Color[] getColors() {
   return new Color[] {properties.getColor()};
 }
コード例 #9
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
 @Override
 public String getPaintedLabel(ChartFrame cf) {
   return (properties.getSF() ? "Fast" : "Slow") + getLabel();
 }
コード例 #10
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
  @Override
  public void calculate() {
    Dataset initial = getDataset();
    int count = 0;
    if (initial != null && !initial.isEmpty()) count = initial.getItemsCount();

    /** ******************************************************************* */
    // This entire method is basically a copy/paste action into your own
    // code. The only thing you have to change is the next few lines of code.
    // Choose the 'lookback' method and appropriate 'calculation function'
    // from TA-Lib for your needs. Everything else should stay basically the
    // same

    // prepare ta-lib variables
    outputFastD = new double[count];
    outputFastK = new double[count];
    outBegIdx = new MInteger();
    outNbElement = new MInteger();

    core = TaLibInit.getCore(); // needs to be here for serialization issues

    // [your specific indicator variables need to be set first]
    periodK = properties.getPeriodK();
    periodD = properties.getPeriodD();
    period = properties.getPeriod();

    // now do the calculation over the entire dataset
    // [First, perform the lookback call if one exists]
    // [Second, do the calculation call from TA-lib]
    lookback = core.stochRsiLookback(period, periodK, periodD, MAType.Sma);
    core.stochRsi(
        0,
        count - 1,
        initial.getCloseValues(),
        period,
        periodK,
        periodD,
        MAType.Sma,
        outBegIdx,
        outNbElement,
        outputFastK,
        outputFastD);

    // Everything between the /***/ lines is what needs to be changed.
    // Everything else remains the same. You are done with your part now.
    /** ******************************************************************* */

    // fix the output array's structure. TA-Lib does NOT match
    // indicator index and dataset index automatically. That's what
    // this function does for us.
    outputFastD = TaLibUtilities.fixOutputArray(outputFastD, lookback);
    outputFastK = TaLibUtilities.fixOutputArray(outputFastK, lookback);

    calculatedDatasetFastD = Dataset.EMPTY(initial.getItemsCount());
    for (int i = 0; i < outputFastD.length; i++)
      calculatedDatasetFastD.setDataItem(i, new DataItem(initial.getTimeAt(i), outputFastD[i]));

    calculatedDatasetFastK = Dataset.EMPTY(initial.getItemsCount());
    for (int i = 0; i < outputFastK.length; i++)
      calculatedDatasetFastK.setDataItem(i, new DataItem(initial.getTimeAt(i), outputFastK[i]));

    addDataset(FASTD, calculatedDatasetFastD);
    addDataset(FASTK, calculatedDatasetFastK);
  }
コード例 #11
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
 @Override
 public Stroke getDelimitersStroke() {
   return properties.getDelimiterLineStroke();
 }
コード例 #12
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
 @Override
 public Color getDelimitersColor() {
   return properties.getDelimiterColor();
 }
コード例 #13
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
 @Override
 public Stroke getZeroLineStroke() {
   return properties.getZeroLineStroke();
 }
コード例 #14
0
ファイル: StochRSI.java プロジェクト: viorelgheba/chartsy
 @Override
 public Color getZeroLineColor() {
   return properties.getZeroLineColor();
 }