WPF Charting Documentation - SciChart WPF Charts SDK v5.x
Head & Shoulders Drawing Tool

The HeadAndShouldersAnnotation allows a user to draw a Head & Shoulders or Inverse Head & Shoulders chart pattern on a price chart. To create this annotation you have to set points at critical turning-points that will be connected by lines and polygons. Those points were limited by BasePointsCount (default value is 6).

Note: The Drawing Tools API in SciChart.Charting.DrawingTools is available in the Enterprise and SDK Editions of SciChart only
The HeadAndShouldersAnnotation

The HeadAndShouldersAnnotation

 

The HeadAndShouldersAnnotation is a CompositeAnnotation (an annotation which consists of a number of other annotations) which consists of:

Additional properties specific to HeadAndShouldersAnnotation include:

Adding HeadAndShouldersAnnotations via mouse click

To add a HeadAndShouldersAnnotation via mouse click you have to add TradingAnnotationCreationModifier to your SciChartSurface.ChartModifier and set AnnotationType as HeadAndShouldersAnnotation. Please see the article on the TradingAnnotationCreationModifier for how to use this type.

Declaring a HeadAndShouldersAnnotation in XAML

To declare a HeadAndShouldersAnnotation in XAML you have to declare the annotation and then declare its InitialBasePoints collection that is actually collection of ComparablePoint objects. ComparablePoint stores X and Y values that are used for placing annotation point. InitialBasePoints collection is limited by BasePointsCount value. And default value is 7.

Declaring a HeadAndShouldersAnnotation in XAML
Copy Code
<!-- XAxis, YAxis, RenderableSeries omitted for brevity -->
<s:SciChartSurface.Annotations>
   <!--Declare HeadAndShouldersAnnotations-->
   <s:HeadAndShouldersAnnotation IsEditable="True">
   <!-- Declare InitialBasePoints collection that is used for
        creating annotation from XAML.
        InitialBasePoints is actually observable collection of
        ComparablePoint-s. ComparablePoint stores X and Y point Value.
   -->
        <s:HeadAndShouldersAnnotation.InitialBasePoints>
           <!-- Placing first point -->
           <s:ComparablePoint X="0"  Y="0"/>
           <!-- Placing second point -->
           <s:ComparablePoint X="2"  Y="4"/>
           <!-- Placing third point -->
           <s:ComparablePoint X="4"  Y="0"/>
                       
           <!-- Placing fourth point -->
           <s:ComparablePoint X="8"  Y="8"/>
           <!-- Placing fifth point -->
           <s:ComparablePoint X="12"  Y="0"/>
           <!-- Placing sixth point -->
           <s:ComparablePoint X="14"  Y="4"/>
           <!-- Placing seventh point -->
           <s:ComparablePoint X="16"  Y="0"/>
         </s:HeadAndShouldersAnnotation.InitialBasePoints>
    </s:HeadAndShouldersAnnotation>
</s:SciChartSurface.Annotations>

Please Note that the HeadAndShouldersAnnotation has limit of 7 base points. As you can see here, you just have to set this 7 points for the annotation: [X1=0; Y1=0], [X2=2; Y2=4], [X3=4; Y3=0], [X4=8; Y4=8], [X5=12; Y5=0], [X6=14; Y6=4] , [X7=16; Y7=0].

 

 

Declaring a HeadAndShouldersAnnotation in Code-Behind

To add a HeadAndShouldersAnnotation in code, simply use the following C# code:

Example Title
Copy Code
// Create a SciChartSurface. XAxis, YAxis omitted for brevity
var sciChartSurface = new SciChartSurface();
// Create a HeadAndShouldersAnnotation.
var headAndShoulder = new HeadAndShoulderAnnotation();
// HeadAndShouldersAnnotation should be added to
//SciChartSurface.Annotation collection first, to make SetBasePoint() method
//works correctly
sciChart.Annotations.Add(headAndShoulder);
// Set first point of HeadAndShouldersAnnotation
headAndShoulder.SetBasePoint(0, 0);
   
// Set second point of HeadAndShouldersAnnotation
headAndShoulder.SetBasePoint(2, 4);
 // Set third point of HeadAndShouldersAnnotation
headAndShoulder.SetBasePoint(4, 0);   
// Set fourth point of HeadAndShouldersAnnotation
headAndShoulder.SetBasePoint(8, 8);
// Set fifth point of HeadAndShouldersAnnotation
headAndShoulder.SetBasePoint(12, 0);
// Set sixth point of HeadAndShouldersAnnotation
headAndShoulder.SetBasePoint(14, 4);
// Set seventh point of HeadAndShouldersAnnotation
headAndShoulder.SetBasePoint(16, 0);

 

Declaring a HeadAndShouldersAnnotation in MVVM

To add an HeadAndShouldersAnnotation via MVVM please follow the instructions for adding annotations with MVVM: Declaring Annotations in MVVM with the AnnotationsBinding Markup Extension

To add a HeadAndShouldersAnnotation via a ViewModel you have to use SciChart markup extension called AnnotationsBinding,

The AnnotationsBinding Markup Extension
Copy Code
<s:SciChartSurface Annotations="{s:AnnotationsBinding Annotations}">
</s:SciChartSurface>

Now you need to create collection for Annotations in ViewModel. Then create and add an HeadAndShouldersAnnotationViewModel to that collection of Annotations like this:

ViewMode
Copy Code
public class MyViewModel : INotifyPropertyChanged
 { 
    public ObservableCollection<IAnnotationViewModel> Annotations { get; }
 
    public void Foo()
    {
        // Create a HeadAndShouldersAnnotation.
        headAndShoulder = new HeadAndShouldersAnnotationViewModel();
        // HeadAndShouldersAnnotation should be added to
        //SciChartSurface.Annotation collection first, to make SetBasePoint() method
        //works correctly
        Annotations.Add(headAndShoulder);
        // Set first point of HeadAndShouldersAnnotation
        headAndShoulder.SetBasePoint(0, 0);
           
        // Set second point of HeadAndShouldersAnnotation
        headAndShoulder.SetBasePoint(2, 4);
         // Set third point of HeadAndShouldersAnnotation
        headAndShoulder.SetBasePoint(4, 0);   
        // Set fourth point of HeadAndShouldersAnnotation
        headAndShoulder.SetBasePoint(8, 8);
        // Set fifth point of HeadAndShouldersAnnotation
        headAndShoulder.SetBasePoint(12, 0);
        // Set sixth point of HeadAndShouldersAnnotation
        headAndShoulder.SetBasePoint(14, 4);
        // Set seventh point of HeadAndShouldersAnnotation
        headAndShoulder.SetBasePoint(16, 0);
    }
 }

 

 

 

 

 

 


SCICHART ® is a Registered Trademark in the UK, US and EU. Copyright SciChart Ltd 2011-2018.

Email us to give feedback!