The PitchforkAnnotation allows a user to draw a Pitchfork or Channel 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).

The PitchforkAnnotation is a CompositeAnnotation (an annotation which consists of a number of other annotations) which consists of:
- LineAnnotations - which are connecting our points
- PolygonAnnotations - that are placed inside the triangles formed by the left/right shoulder and the head
- Text labels - which are TextAnnotations
Additional properties specific to HeadAndShouldersAnnotation include:
- SidesFill - defines the style for the outer polygon fils
- MiddleFill - defines the style for the inner polygon fils
Adding a PitchforkAnnotation via mouse click
To add a PitchforkAnnotation via mouse click you have to add TradingAnnotationCreationModifier to your SciChartSurface.ChartModifier and set AnnotationType as PitchforkAnnotation. Please see the article on the TradingAnnotationCreationModifier for how to use this type.
Declaring a PitchforkAnnotation in XAML
To declare a PitchforkAnnotation 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 3.
Declaring a PitchforkAnnotation in XAML |
Copy Code
|
---|---|
<!-- XAxis, YAxis, RenderableSeries omitted for brevity --> <s:SciChartSurface.Annotations> <!--Declare PitchforkAnnotation--> <s:PitchforkAnnotation 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:PitchforkAnnotation.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"/> </s:PitchforkAnnotation.InitialBasePoints> </s:PitchforkAnnotation> </s:SciChartSurface.Annotations> |
Please Note that the PitchforkAnnotation has limit of 3 base points. As you can see here, you just have to set these 3 points for the annotation: [X1=0; Y1=0], [X2=2; Y2=4], [X3=4; Y3=0]
Declaring a PitchforkAnnotation in Code-Behind
To add a PitchforkAnnotation 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 PitchforkAnnotationAnnotation. var pitchfork = new PitchforkAnnotation(); // PitchforkAnnotationAnnotation should be added to //SciChartSurface.Annotation collection first, to make SetBasePoint() method //works correctly sciChart.Annotations.Add(pitchfork); // Set first point of PitchforkAnnotationAnnotation pitchfork.SetBasePoint(0, 0); // Set second point of PitchforkAnnotationAnnotation pitchfork.SetBasePoint(2, 4); // Set third point of PitchforkAnnotationAnnotation pitchfork.SetBasePoint(4, 0); |
Declaring a PitchforkAnnotation in MVVM
To add a PitchforkAnnotation via MVVM please follow the instructions for adding annotations with MVVM: Declaring Annotations in MVVM with the AnnotationsBinding Markup Extension
To add a PitchforkAnnotation 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 PitchforkAnnotationViewModel to that collection of Annotations like this:
ViewMode |
Copy Code
|
---|---|
public class MyViewModel : INotifyPropertyChanged { public ObservableCollection<IAnnotationViewModel> Annotations { get; } public void Foo() { // Create a PitchforkAnnotationAnnotation. pitchfork = new PitchforkAnnotationViewModel(); // PitchforkAnnotationAnnotation should be added to //SciChartSurface.Annotation collection first, to make SetBasePoint() method //works correctly Annotations.Add(pitchfork); // Set first point of PitchforkAnnotationAnnotation pitchfork.SetBasePoint(0, 0); // Set second point of PitchforkAnnotationAnnotation pitchfork.SetBasePoint(2, 4); // Set third point of PitchforkAnnotationAnnotation pitchfork.SetBasePoint(4, 0); } } |