Bar with dash

moti

Member
Joined
Dec 19, 2023
Posts
9
Likes
3
Hello,

I like to create a bar with a colored dash in it. I can not get it to work. I want the dash to be the width of the bar and have a line size that scales with the graph.

I tried the following (and lots more):
  • a not continuous line, still draws a continuous line (do not understand what continuous intends, manual: Sets the continuous option for the path)
Code:
PathDescriptor pathDescriptor1 = new PathDescriptor(Inputs.DASH_ON_BAR, "A dash on a bar", Color.RED, 3, null);
pathDescriptor.setContinuous(false);
  • a line of dashes, which draws a line of dashes, however the size does not follow the Enums.Size argument (the dash looks always small) and the dash not scale with the graph (tried to set width to 0 with setFixedWidth for auto sizing, manual: Sets the fixed width for displaying bars (null for dynamic width). As a result with a few bars on the screen a very small dash is shown.
Code:
PathDescriptor pathDescriptor1 = new PathDescriptor(Inputs.DASH_ON_BAR, "A dash on a bar", Color.RED, Enums.PointType.DASH, Enums.Size.LARGE, true, false, true);
pathDescriptor.setContinuous(false);
pathDescriptor.setFixedWidth(0);
Code used to fill the line:
Code:
rd.declarePath(Values.DASH_ON_BAR, Inputs.POC_BAR);

Code:
dataContext.getDataSeries().setPathColor(index, Values.DASH_ON_BAR, color);
dataContext.getDataSeries().setDouble(index, Values.DASH_ON_BAR, price);
dataContext.getDataSeries().setComplete(index);

I do not like to use markers as it will just create a marker per bar and these do not scale. I have a working solution in a figure, that just draws dashes in all visible bars, I want to get rid of that as it is a special. It should be possible with the descriptors somehow, I think.

How to do this with a descriptor (dash has width of bar and dash line size that scales with the size of the chart) ?
Moti.
 
like this, as I made in a Figure (with drawContext.getBarWidth and drawContext.getTckheight), but want to have in the regular drawing mechanism with the descriptors (for scroll smoothness)
1721995650016.png
 
Maybe I'm not fully understanding what you are trying to accomplish but I would use Line:

https://www.motivewave.com/sdk/javadoc/com/motivewave/platform/sdk/draw/Line.html<init>(long,double,long,double,com.motivewave.platform.sdk.common.PathInfo)

Basic idea below. Where I have getSetting...BOTTOM_GUIDE you would put in your path info.

Java:
        int index = series.size()-1;
        
        if (index >= 0)
        {
            
            for (int i = 0; i <= index; i++)
            {
                double mid = (series.getHigh(i) / series.getLow(i));
                var line = new Line(series.getStartTime(i), mid, series.getEndTime(i), mid, getSettings().getPath(Inputs.BOTTOM_GUIDE));
                addFigure(line);
            }
        }
 
Thank you for the answer, I already posted my own answer in this thread but the answer is removed (like other answers of me in other threads from three weeks ago), so again:

In the end I released it by using a PriceBarDescriptor with as priceBarTtype Enums.PriceBarType.FLATSTICK and setting the value for the dataSeries to a PriceData object.

Something like this:

Code:
// initialize
pocBarGroup.addRow(new PriceBarDescriptor(Inputs.LINE, "A dash on a bar", Enums.PriceBarType.FLATSTICK, Enums.BarInput.CLOSE, true, true));
rd.declarePriceBar(Values.LINE, Inputs.LINE);

// set price
dataContext.getDataSeries().setValue(index, Values.LINE, new PriceData(price + halfTickSize, price + halfTickSize, price - halfTickSize, price - halfTickSize, barColor));
dataContext.getDataSeries().setComplete(index, Values.LINE);

The height and witdth of the dash (priceBar) are scaled by Motivewave.
 
Top