scaling volume

34 views
Skip to first unread message

Klaus

unread,
Jun 6, 2011, 3:18:15 AM6/6/11
to JBookTrader
Hi,

I am wondering: if I zoom in the backtest chart all graphs are
rescaled on the y-axis: with one exception - the volume. Is there a
way to fix this?
In particular, it would also be nice if the volume would not be in
bottom-most or top-most pixel, as this makes the graph hard to read.

Thanks
Klaus

Eugene Kononov

unread,
Jun 6, 2011, 7:16:59 AM6/6/11
to jbook...@googlegroups.com
Can you post your chart so that I understand what you are referring to?


--
You received this message because you are subscribed to the Google Groups "JBookTrader" group.
To post to this group, send email to jbook...@googlegroups.com.
To unsubscribe from this group, send email to jbooktrader...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en.


Klaus

unread,
Jun 6, 2011, 1:17:16 PM6/6/11
to JBookTrader
Dear Eugene,
I send it via email as groups does not allow attachments. (any more)

Klaus

ShaggsTheStud

unread,
Jun 6, 2011, 6:16:48 PM6/6/11
to jbook...@googlegroups.com
In the past I have adjusted the auto zoom so it gives +/-10% to the range so the upper most and lower most data always show.

nonlinear

unread,
Jun 7, 2011, 7:20:34 PM6/7/11
to jbook...@googlegroups.com
Klaus was referring to the "Net Profit" chart, which doesn't scale the chart quite right when zoomed in. Yes, this is a known issue, and I'll address it in one of the upcoming releases.

Judson Wilson

unread,
Jun 8, 2011, 2:15:53 AM6/8/11
to JBookTrader
I made a couple of changes in my latest commit, which I hope everyone
likes.

Klaus, you can download the latest version of the relevant file here:
http://jbooktrader.googlecode.com/hg/source/com/jbooktrader/platform/chart/DateScrollBar.java?r=661913f1ef9f468b4319fd2f58ecf6ed7f90483a

You can figure out the folder it goes in by looking at the top line of
the file.

Let me know what you think.

- Judson

nonlinear

unread,
Jun 8, 2011, 8:43:14 PM6/8/11
to jbook...@googlegroups.com

On Wednesday, June 8, 2011 2:15:53 AM UTC-4, Judson Wilson wrote:
I made a couple of changes in my latest commit, which I hope everyone
likes.

Klaus, you can download the latest version of the relevant file here:
http://jbooktrader.googlecode.com/hg/source/com/jbooktrader/platform/chart/DateScrollBar.java?r=661913f1ef9f468b4319fd2f58ecf6ed7f90483a



I tested this, and it works. The Net Profit charts rescales as expected when zoomed in. Thanks, Judson. Another thing that I would do is to make the Net Profit line a little thicker. Klaus, please see if Judson's fix works for you. If so, I'll include it in the next release.
 

nonlinear

unread,
Jun 8, 2011, 9:25:31 PM6/8/11
to jbook...@googlegroups.com
Judson, I think the combined chart looks better when your EXTRA_MARGIN_FACTOR is applied to Net Profit chart, but not to the OHLC charts.


chart.png

nonlinear

unread,
Jun 8, 2011, 9:44:15 PM6/8/11
to jbook...@googlegroups.com
Judson, if you find time and motivation, perhaps you could do something about the other mildly annoying chart problem. Look at the attached chart. Notice how the "buy" and the "sell" annotations are positioned? It looks odd because the annotations are not on the price line. The chart is in fact totally correct, but because the price resolution is 5 minute OHLC bars and the executions are plotted with a 1-second resolution, they seem to exist as independent entities. I think the right way to handle it is to "snap" the "buy/sell" annotations to the corresponding price bar.

What do you guys think?


chart2.png

Judson Wilson

unread,
Jun 8, 2011, 9:50:08 PM6/8/11
to jbook...@googlegroups.com
In an ideal world I would base the margin on pixels, rather than percent.  I personally don't see much of a difference on OHLC bars when the graphs aren't very tall, but the price graph tends to devote a little too much real estate.  *Shrug*  You could disable it for the bars, that would just require a little more work.

On Wed, Jun 8, 2011 at 6:25 PM, nonlinear <eugene....@gmail.com> wrote:
Judson, I think the combined chart looks better when your EXTRA_MARGIN_FACTOR is applied to Net Profit chart, but not to the OHLC charts.

--
You received this message because you are subscribed to the Google Groups "JBookTrader" group.
To view this discussion on the web visit https://groups.google.com/d/msg/jbooktrader/-/SGzM5Lb-j_IJ.

Judson Wilson

unread,
Jun 8, 2011, 10:23:22 PM6/8/11
to jbook...@googlegroups.com
On Wed, Jun 8, 2011 at 6:44 PM, nonlinear <eugene....@gmail.com> wrote:
Judson, if you find time and motivation, perhaps you could do something about the other mildly annoying chart problem. Look at the attached chart. Notice how the "buy" and the "sell" annotations are positioned? It looks odd because the annotations are not on the price line. The chart is in fact totally correct, but because the price resolution is 5 minute OHLC bars and the executions are plotted with a 1-second resolution, they seem to exist as independent entities. I think the right way to handle it is to "snap" the "buy/sell" annotations to the corresponding price bar.

What do you guys think?

In my opinion, the "correct" thing to do would be to make the width of the bars such that there is very little gap between them.  Then the bubble would appear to occur somewhere in the middle of the bar.  This might be terribly ugly, though.

Actually, here is a quick implementation for that effect.  Note it is HORRIBLY SLOW because JFreeChart is a turd, performance wise, in general, but this auto-width calculation method for the candles re-computes the width for each individual bar, by sifting through the dataset and looking for the smallest bar spacing (again, it does this calculation for every bar).  This could be implemented by hand because we already know the bar width, which would be much much faster.

Anyways, here is the replacement chunk of code, which can easily be tweaked to look a little bit better.  You must zoom in substantially to see the effect:

    private void createChart() {
        CandlestickRenderer candleRenderer = new CandlestickRenderer(-1);
        candleRenderer.setDrawVolume(false);
        candleRenderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
        candleRenderer.setAutoWidthGap(0.0);
        candleRenderer.setAutoWidthFactor(1.0);
        candleRenderer.setUpPaint(Color.GREEN);
        candleRenderer.setDownPaint(Color.RED);
        candleRenderer.setSeriesPaint(0, new Color(250, 240, 150));
        candleRenderer.setBaseStroke(new BasicStroke(1));

Judson Wilson

unread,
Jun 8, 2011, 10:28:50 PM6/8/11
to jbook...@googlegroups.com
Also notice that there is a built in volume charting capability.. maybe something worth looking into?

Klaus

unread,
Jun 9, 2011, 12:57:13 PM6/9/11
to JBookTrader
Dear Judson,

thanks a lot for the patch. It works nicely. it is exactly what I was
looking for.

Regarding the buy and sell positioning. I would actually, given the
overall limitations
I would prefer it as it is over a "snapped" representation. This way,
one can roughly estimate where the buy / sell was
and if multiple fall into the gap, you see even the order..

Klaus

On 9 Jun., 04:28, Judson Wilson <wilson.jud...@gmail.com> wrote:
> Also notice that there is a built in volume charting capability.. maybe
> something worth looking into?
>
> On Wed, Jun 8, 2011 at 7:23 PM, Judson Wilson <wilson.jud...@gmail.com>wrote:
Reply all
Reply to author
Forward
0 new messages