|
From: Josh T. <nli...@ya...> - 2010-11-17 12:39:55
|
Alex,
First, "org.charty.macd" and "org.charty.ema" are mispelled. They are missing the "s" in chartsy. That's why they aren't valid packages.
Next, if you have created a module in Chartsy to build your chart, do the following:-Right click the Chartsy Project Module in the "Project" Panel.-Select "sources" in the left pane.-Your module should appear in the right pane in the long list of Chartsy modules. If not, select "add" and find your module. This should not be your problem though but covering all bases here.
for whatever reason, I've found on two occasions that a module (random) stops showing up in that list on my system. Not sure if it's something I'm doing when building/compiling/submitting or what but it seems rare and sporadic for now so I'm not worried.
Now, if the above doesn't fix your problem, go into the Project panel again, got to Chartsy project, open the "modules" folder, and find your module. If you did the above, it's visible in the list in this folder.- double click your module and then scroll down/up in the project pane to where it is opened.- Right click your opened module and select "properties"- Select Libraries in the left pane- Select "Module Dependencies" tab in the right pane- you should see "Moving Average Convergence/Divergence" and "Exponential Moving Average" listed in the module dependencies. If not, add them via "Add Dependency."
Inside the Chartsy project, all modules are accessible only in so far as you identify them as dependencies. This is the Netbeans approach as well and it's a very solid approach to creating, protecting, and managing code. If none of this works, let us know.
Josh
--- On Wed, 11/17/10, Alex Lourie <dj...@gm...> wrote:
From: Alex Lourie <dj...@gm...>
Subject: Re: [Chartsy-devel] Developing a new chart
To: cha...@li...
Date: Wednesday, November 17, 2010, 5:56 AM
Hi Viorel
How do I:
1. Make sure that EMA and MACD packages are included in project libraries (I've added them as non-api module dependencies in NetBeans. Is it enough?).
2. Make EMA and MACD public packages - How do I do that?
In addition, I've added your example code but NetBeans doesn't "see" org.charty.macd and org.charty.ema as valid packages.
Thank you for your help.
On Wed, Nov 17, 2010 at 12:17 PM, Alex Lourie <dj...@gm...> wrote:
Hi Viorel!
Thank you so much for the help. I've tried to do this on my own and came up with something similar.
I now only have 2 questions:
1. I think that the more correct code would be:
if (emaDataset.getDataItem(i) != null && emaDataset.getDataItem(i-1) != null
&& macdDataset.getDataItem(i) != null && macdDataset.getDataItem(i-1) != null)
{
if (emaDataset.getCloseAt(i) > emaDataset.getCloseAt(i-1) && macdDataset.getCloseAt(i) > macdDataset.getCloseAt(i-1) )
g.setColor(Color.GREEN);
else if (emaDataset.getCloseAt(i) < emaDataset.getCloseAt(i-1) && macdDataset.getCloseAt(i) < macdDataset.getCloseAt(i-1))
g.setColor(Color.RED);
else
g.setColor(Color.BLUE);
}
2. Should it just compile? I had a problem at home with compiling this module for some reason...
On Wed, Nov 17, 2010 at 11:24 AM, Viorel Gheba <vio...@gm...> wrote:
Hi Alex
I tried to make a chart as you described.
This is the code that i used:
package org.chartsy.testmodule;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import org.chartsy.ema.EMA;
import org.chartsy.ema.OverlayProperties;
import org.chartsy.macd.IndicatorProperties;
import org.chartsy.macd.MACD;
import org.chartsy.main.ChartFrame;
import org.chartsy.main.ChartProperties;
import org.chartsy.main.chart.Chart;
import org.chartsy.main.data.ChartData;
import org.chartsy.main.data.Dataset;
import org.chartsy.main.utils.CoordCalc;
import org.chartsy.main.utils.Range;
import org.chartsy.main.utils.SerialVersion;
import org.chartsy.main.utils.StrokeGenerator;
/**
*
* @author Viorel
*/
public class TestChart extends Chart
{
private static final long serialVersionUID =
SerialVersion.APPVERSION;
private EMA ema;
private MACD macd;
private Dataset mainDataset;
public TestChart()
{
ema = new EMA();
OverlayProperties emaProps =
ema.getNode().getLookup().lookup(OverlayProperties.class);
emaProps.setPeriod(13);
macd = new MACD();
IndicatorProperties macdProps =
macd.getNode().getLookup().lookup(IndicatorProperties.class);
macdProps.setFast(12);
macdProps.setSlow(26);
macdProps.setSmooth(9);
}
private void setDataset(Dataset dataset)
{
if (mainDataset == null)
{
mainDataset = dataset;
calculateDatasets();
}
else if (!mainDataset.equals(dataset))
{
mainDataset = dataset;
calculateDatasets();
}
}
private void calculateDatasets()
{
ema.setDataset(mainDataset);
ema.calculate();
macd.setDataset(mainDataset);
macd.calculate();
}
@Override public String getName()
{
return "Test Chart";
}
@Override public void paint(Graphics2D g, ChartFrame cf)
{
setDataset(cf.getChartData().getDataset());
ChartData cd = cf.getChartData();
ChartProperties cp = cf.getChartProperties();
Rectangle rect =
cf.getSplitPanel().getChartPanel().getBounds();
rect.grow(-2, -2);
Range range = cf.getSplitPanel().getChartPanel().getRange();
Dataset dataset = cd.getVisible();
Dataset emaDataset = ema.visibleDataset(cf, EMA.EMA);
Dataset macdDataset = macd.visibleDataset(cf,
MACD.HISTOGRAM);
if (dataset != null && emaDataset != null &&
macdDataset != null)
{
g.setStroke(StrokeGenerator.getStroke(3));
int count = emaDataset.getItemsCount();
for (int i = 0; i < count; i++)
{
double open = dataset.getOpenAt(i);
double close = dataset.getCloseAt(i);
double high = dataset.getHighAt(i);
double low = dataset.getLowAt(i);
double x = cd.getX(i, rect);
double yOpen = cd.getY(open, rect, range);
double yClose = cd.getY(close, rect, range);
double yHigh = cd.getY(high, rect, range);
double yLow = cd.getY(low, rect, range);
double candleWidth = cp.getBarWidth();
if (emaDataset.getDataItem(i) != null
&& macdDataset.getDataItem(i) != null)
{
if (emaDataset.getCloseAt(i) > close
&& macdDataset.getCloseAt(i) > 0)
g.setColor(Color.GREEN);
else if (emaDataset.getCloseAt(i) < close
&& macdDataset.getCloseAt(i) < 0)
g.setColor(Color.RED);
else
g.setColor(Color.BLUE);
}
else
{
g.setColor(Color.BLUE);
}
g.draw(CoordCalc.line(x, yLow, x, yHigh));
g.draw(CoordCalc.line(x, yOpen, x - candleWidth/2,
yOpen));
g.draw(CoordCalc.line(x, yClose, x + candleWidth/2,
yClose));
}
}
}
}
You ca see that I copied the OHLC code.
Note:
- Make sure that EMA and MACD packages are included in your project
libraries.
- Make EMA and MACD public packages.
For more questions, please contact us.
Best regards,
Viorel
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Chartsy-devel mailing list
Cha...@li...
https://lists.sourceforge.net/lists/listinfo/chartsy-devel
--
Alex Lourie
--
Alex Lourie
-----Inline Attachment Follows-----
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
-----Inline Attachment Follows-----
_______________________________________________
Chartsy-devel mailing list
Cha...@li...
https://lists.sourceforge.net/lists/listinfo/chartsy-devel
|