iOS & macOS Charting Documentation - SciChart iOS & macOS Charts SDK v4.x

The SCIXabcdAnnotation

The SCIXabcdAnnotation is a specialized multi-point trading annotation used to draw harmonic patterns such as Gartley, Butterfly, Bat, and Crab. These patterns consist of five key points: X, A, B, C, and D, which help identify potential reversal zones in financial charts.

Xabcd Annotation

NOTE: Examples of the Annotations usage can be found in the SciChart iOS Examples Suite as well as on GitHub:

The SCICompositeAnnotation class provides the SCICompositeAnnotation.borderPen and SCICompositeAnnotation.fillBrush properties, which are used for the annotation outline and background and expects the SCIPenStyle and SCIBrushStyle correspondingly. To learn more about Pens and Brushes and how to utilize them, please refer to the SCIPenStyle, SCIBrushStyle and SCIFontStyle article.

NOTE: To learn more about Annotations in general - please see the Common Annotation Features article.

Structure and Points

The SCIXabcdAnnotation is defined by five base points, added sequentially using the setBasePointWithX(:y) method:

  • Point 0 (X): Starting point of the pattern
  • Point 1 (A): First leg of the pattern
  • Point 2 (B): Retracement from A
  • Point 3 ©: Extension from B
  • Point 4 (D): Final point completing the harmonic structure kDPointIndex = 4 indicates the index of the final D point.

Behavior

  • Lines are drawn between XA, AB, BC, and CD.
  • Additional helper (often dashed) lines may connect XB, AC, BD, and XD.
  • Two filled regions are typically formed:
    • Triangle XAB
    • Triangle BCD

The SCIXabcdAnnotation can be configured using the properties and method listed in the table below:

Field Description
SCIXabcdAnnotation.showRatios Determines whether calculated harmonic ratios are displayed on the chart.

Define Points

Points are added sequentially using [annotation setBasePointWithX: y:];. Each call adds the next point in order (X → A → B → C → D). The annotation is fully formed once all five points are provided.

NOTE: The xAxisId and yAxisId must be supplied if you have axis with non-default Axis Ids, e.g. in multi-axis scenario.

Create a XabcdAnnotation

A SCIXabcdAnnotation can be added onto a chart using the following code:

// Assume a surface has been created and configured somewhere id surface; SCIXabcdAnnotation *xAbcdAnn = [[SCIXabcdAnnotation alloc] init]; // Define points (X, A, B, C, D) [xAbcdAnn setBasePointWithX:@224 y:@7]; // X [xAbcdAnn setBasePointWithX:@230 y:@4]; // A [xAbcdAnn setBasePointWithX:@235 y:@5]; // B [xAbcdAnn setBasePointWithX:@240 y:@6]; // C [xAbcdAnn setBasePointWithX:@245 y:@7]; // D // Customize appearance xAbcdAnn.fillBrush = [[SCISolidBrushStyle alloc] initWithColorCode:0x55AAAA00]; xAbcdAnn.stroke = [[SCISolidPenStyle alloc] initWithColorCode:0xFFe97064 thickness:2.0]; // Enable interaction and ratios xAbcdAnn.isEditable = YES; xAbcdAnn.showRatios = YES; // Add to chart surface [self.surface.annotations add:xAbcdAnn];
// Assume a surface has been created and configured somewhere let surface: ISCIChartSurface let xAbcdAnn = SCIXabcdAnnotation() // Add points xAbcdAnn.setBasePointWithX(NSNumber(value: 224), y: NSNumber(value: 7)) // X xAbcdAnn.setBasePointWithX(NSNumber(value: 230), y: NSNumber(value: 4)) // A xAbcdAnn.setBasePointWithX(NSNumber(value: 235), y: NSNumber(value: 5)) // B xAbcdAnn.setBasePointWithX(NSNumber(value: 240), y: NSNumber(value: 6)) // C xAbcdAnn.setBasePointWithX(NSNumber(value: 245), y: NSNumber(value: 7)) // D // Customize appearance xAbcdAnn.fillBrush = SCISolidBrushStyle(color: 0x55AAAA00) xAbcdAnn.stroke = SCISolidPenStyle(color: 0xFFe97064, thickness: 2) // Enable interaction and ratios xAbcdAnn.isEditable = true xAbcdAnn.showRatios = true // Add to chart surface self.surface.annotations.add(items: xAbcdAnn)

NOTE: For interactive creation of SCIXabcdAnnotation, use the corresponding annotation creation modifier SCIXabcdCreationModifier available in SciChart iOS.

NOTE: To learn more about other Annotation Types, available out of the box in SciChart, please find the comprehensive list in the Annotation APIs article.