usingcAlgo.API;namespacecAlgo{// This sample shows how to use the PenLineCap properties of shapes[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]publicclassPenLineCapSample:Indicator{[Parameter("Stroke Start Line Cap", DefaultValue = PenLineCap.Flat)]publicPenLineCapStrokeStartLineCap{get;set;}[Parameter("Stroke End Line Cap", DefaultValue = PenLineCap.Flat)]publicPenLineCapStrokeEndLineCap{get;set;}[Parameter("Stroke Dash Cap", DefaultValue = PenLineCap.Flat)]publicPenLineCapStrokeDashCap{get;set;}protectedoverridevoidInitialize(){varrectangle=newRectangle{HorizontalAlignment=HorizontalAlignment.Center,VerticalAlignment=VerticalAlignment.Center,StrokeStartLineCap=StrokeStartLineCap,StrokeEndLineCap=StrokeEndLineCap,StrokeDashCap=StrokeDashCap,StrokeColor=Color.Red,StrokeThickness=4,Width=200,Height=100,};Chart.AddControl(rectangle);}publicoverridevoidCalculate(intindex){}}}
1 2 3 4 5 6 7 8 9101112131415161718
importclrclr.AddReference("cAlgo.API")fromcAlgo.APIimport*classTest():definitialize(self):rectangle=Rectangle()rectangle.HorizontalAlignment=HorizontalAlignment.Centerrectangle.VerticalAlignment=VerticalAlignment.Center# StrokeStartLineCap, StrokeEndLineCap, and StrokeDashCap# are parameters of type PenLineCap defined in indicator C# filerectangle.StrokeStartLineCap=api.StrokeStartLineCaprectangle.StrokeEndLineCap=api.StrokeEndLineCaprectangle.StrokeDashCap=api.StrokeDashCaprectangle.StrokeColor=Color.Redrectangle.StrokeThickness=4rectangle.Width=200rectangle.Height=100api.Chart.AddControl(rectangle)
Fields
Flat
Summary
A cap that does not extend past the last point of the line. Comparable to no line cap.
Signature
1
PenLineCap.Flat;
Return Value
PenLineCap
Square
Summary
A rectangle that has a height equal to the line thickness and a length equal to half the line thickness.
Signature
1
PenLineCap.Square;
Return Value
PenLineCap
Round
Summary
A semicircle that has a diameter equal to the line thickness.
Signature
1
PenLineCap.Round;
Return Value
PenLineCap
Triangle
Summary
An isosceles right triangle whose base length is equal to the thickness of the line.