troubleshooting Question

OHLC chart

Avatar of gbcbr
gbcbrFlag for Cyprus asked on
Java
74 Comments6 Solutions1121 ViewsLast Modified:
Please advice how to create OHLC chart from this dataset:
public class ChartCommander {

    LineEURUSD lineEURUSD;
    List<Date> datesArrayList = new ArrayList<Date>();
    ArrayList pricesArrayList;
    DefaultHighLowDataset dhld;
    String title;
    Comparable s1;
    RegularTimePeriod period;
    java.util.Date[] avg_ts;
    java.util.Date startDate;
    long interval;

    double open;
    double high;
    double low;
    double close;
    double[] prices;
    java.util.Date dates;

    //  TimeSeries s1;

    private static ChartCommander instance = new ChartCommander();

    public static ChartCommander getInstance() {
        return instance;
    }

    public ChartCommander() {

        lineEURUSD = new LineEURUSD(title);
        datesArrayList = new ArrayList();
        pricesArrayList = new ArrayList();
        interval = 10000L;
    }

    public void chartEURUSD(double[] avg, java.util.Date[] avg_ts,
                            double[] outY) {

        if (avg[0] != 0) {
            System.out.println("CC avg[0]    = " + avg[0]);
            System.out.println("CC avg_ts[0]    = " + avg_ts[0]);

            datesArrayList.add(avg_ts[0]);
            pricesArrayList.add(new Double(avg[0]));
            java.util.Date[] myDates =
                new java.util.Date[datesArrayList.size()];
            for (int j = 0; j < myDates.length; j++) {
                myDates[j] = (java.util.Date)datesArrayList.get(j);
            }
            double[] myPrices = new double[pricesArrayList.size()];
            for (int j = 0; j < myPrices.length; j++) {
                myPrices[j] = ((Double)pricesArrayList.get(j)).doubleValue();
            }

            System.out.println("Dates: ");
            for (int j = 0; j < myDates.length; j++) {
                System.out.println(myDates[j].toString());
            }
            System.out.println("Prices: ");

            for (int j = 0; j < myPrices.length; j++) {
                System.out.println(myPrices[j]);
            }
            System.out.println("interval: " + interval);

            DefaultHighLowDataset dataset =
                OHLCData(myDates, myPrices, myDates[0], interval);

            lineEURUSD.doEvent_avg(avg);
        }
        if (outY[0] != 0) {
            System.out.println("CC outY[0]    = " + outY[0]);

            lineEURUSD.doEvent_outY(outY);
        }
    }
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 6 Answers and 74 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 6 Answers and 74 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros