ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Comparision Finance chart with returns
Posted by Brad on Jun-18-2011 10:42
Hi Peter,

I was wondering whether below can be done? if so how easily.

Say we have finance chart with weekly prices of SPY and GLD on main chart.

Now below that (may be in another box) we want weekly return in % of SPY and GLD as a bar (like volume bars)
However for every period (in this case week) we need two bars (one for SPY and other GLD) in different color.
Also positive return bar would be above x axis and negative return bar would be below x axis. Positive and negative returns are in different color. So total 4 colors.

Thanks

  Re: Comparision Finance chart with returns
Posted by Peter Kwan on Jun-21-2011 00:21
Hi Brad,

You may add a blank indicator chart, and then add a multi-stacked bar layer to the blank indicator chart to create a multi-bar chart with 4 colors in 2 bars. The positive and negative part can be specified similar to the "Positive Negative Bars" sample code.

For example, in Java/C#, it is like:

XYChart myIndicator = myFinanceChart.addIndicator(80);
BarLayer layer = myIndicator.addBarLayer(Chart.Stack);

// The SPY bar
layer.addDataGroup("SPY");
layer.addDataSet(new ArrayMath(SPYData).selectGEZ(null, Chart.NoValue).result(), color1, "+SPY");
layer.addDataSet(new ArrayMath(SPYData).selectLTZ(null, Chart.NoValue).result(), color2, "-SPY");

// Add GLD bar
layer.addDataGroup("GLD");
layer.addDataSet(new ArrayMath(GLDData).selectGEZ(null, Chart.NoValue).result(), color3, "+GLD");
layer.addDataSet(new ArrayMath(GLDData).selectLTZ(null, Chart.NoValue).result(), color4, "-GLD");


Hope this can help.

Regards
Peter Kwan