SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Answered
0
0

Hello,

I am trying to pass multiple custom symbols both (up and down arrows) on multipane stock chart in such a manner that green symbols should be below OHLC candle and red symbols above OHLC candles but I cannot place it in proper manner

Can anyone please help me out with how to give positioning on X axis as it is an year scale?

Version
2.3
Images
  • You must to post comments
Best Answer
1
0

Given the CreateMultiPaneStockChartFragment.java in our example,

you can add some code similar to this to position multiple annotations on the main chart.

    AnnotationCollection annotations = surface.getAnnotations();
    double[] xValues = new double[10];
    double[] yValues = new double[10];
    for(int i = 0; i < 10; i++)
    {
        IAnnotation annotation = sciChartBuilder.newCustomAnnotation().withPosition(xValues[i], yValues[i]).withVerticalAnchorPoint(VerticalAnchorPoint.Bottom).build();
        annotations.add(annotation);
    }

where xValues should be a list of indices to your candlesticks where you want to place annotations. E.g. if you have 100 candles and want to place buy markers at candles 10, 20 and 30 then the values should be 10, 20 and 30.

The yValues should be prices.

To position the annotations ABOVE a candle use this code:

IAnnotation annotation = sciChartBuilder.newCustomAnnotation().withPosition(xIndex, candleHighValue).withVerticalAnchorPoint(VerticalAnchorPoint.Bottom).build();

To position an annotation BELOW a candle, use this code:

IAnnotation annotation = sciChartBuilder.newCustomAnnotation().withPosition(xIndex, candleLowValue).withVerticalAnchorPoint(VerticalAnchorPoint.Top).build();

The VerticalAnchorPoint changes the alignment of the annotation according to this diagram.

enter image description here

Best regards,
Andrew

  • You must to post comments
Best Answer
1
0

Hi Ghousia,

If you’re using CustomAnnotation API for displaying arrows I would suggest to change anchor points for arrows to allign them in a such way that arrow’s end will point to X1/Y1 coords of annotation.

For green arrow which points up you need to set HorizontalAnchorPoint.Center and VerticalAnchorPoint.Top anchor points:

sciChartBuilder.newCustomAnnotation()
                            .withPosition(xCoordToPointAt, yCoordToPointAt)
                            .withContent(R.green_arrow_view)
                            .withHorizontalAnchorPoint(HorizontalAnchorPoint.Center)
                            .withVerticalAnchorPoint(VerticalAnchorPoint.Top)
                            .build()

For red arrow which points down you need to set HorizontalAnchorPoint.Center and VerticalAnchorPoint.Bottom anchor points:

 sciChartBuilder.newCustomAnnotation()
                            .withPosition(xCoordToPointAt, yCoordToPointAt)
                            .withContent(R.red_arrow_view)
                            .withHorizontalAnchorPoint(HorizontalAnchorPoint.Center)
                            .withVerticalAnchorPoint(VerticalAnchorPoint.Bottom)
                            .build()

Hope this will help you!

Best regards,
Yura

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.