Creating an annotation
Create it, set it, add it to a group. From then on it is drawn.Line, Rectangle, Text, HorizontalLine, VerticalLine, HorizontalRay, Ellipse, Triangle, ArrowUp, ArrowDown, Diamond.
To change an annotation later, set its properties again. To remove it, call group.RemoveAnnotation(annotation).
Coordinates
By default the coordinates are absolute: a bar and a value of the Y axis.Y,Y2are prices (or values of the area the annotation is in).X,X2are positions on the bars: the bar of indexiis ati + 1. A bar is one unit wide, fromi + 0.5toi + 1.5. A value beyond the last bar is in the future.
CoordinateXType and CoordinateYType:
Groups
Annotations are kept in groups. The indicator has two of its own:
A group holds either annotations or other groups, not both. For a few annotations, add them directly to
IndVars.Ann_List. When you have different kinds, create one group per kind:
OnLoad.
Showing, hiding and layering a group
Two properties of a group apply to everything it contains:Visible:falsehides the group without removing its annotations.PlotForeground: where its annotations are drawn, relative to the bars.
A value set on a group also holds for the groups inside it, and it wins over the
PlotForeground of the annotations.
MaxCountShown at -1 (the default) there is no limit, otherwise only the last annotation of the group and the MaxCountShown before it are drawn.
All three can come from a parameter of the indicator, so the user changes them without a new calculation: see Parameters resolved by the chart.
Which area
An annotation is drawn in the main area of the chart (the price) unless you say otherwise:Text
A text with
\n is drawn on several lines, centered on each other.
A text that must fit in a space
WithTextOnlyInside, a Text (or a MultiTextLine, by its widest line) is drawn only when it fits between X2 and X3. They are in the unit of X, in any order, and the alignment does not matter: X stays the point of the text. The chart checks it when it draws, with the real size of the text, so the indicator does not measure anything and the check also works for an indicator calculated on the server.
- A side left at
0has no limit. When only one is given, it limits the side ofXwhere it is. - Without
X2andX3,TextOnlyInsideon aTextmeans: only when it fits in the width of a bar.
Labels that do not overlap: MultiTextStack
AMultiTextStack holds Text annotations, added with AddToList, each at its own X and Y as a normal text. When it draws them, the chart:
- leaves out the texts which do not fit between their
X2andX3(TextOnlyInside); - piles up the texts at the same point (same
X,YandTextAlign) in the order of the list, as the lines of aMultiTextLine: the first stays at the point, the others go above it for texts above their point (...HBottom) and below it for the others; - moves apart vertically the texts which overlap, as little as possible and in the order of their
Y. A column is made of the texts whose boxes overlap horizontally; - draws a vertical line of
LineWidthpixels, in the color of the text, from a text that moved to itsY(0: no line). A text piled at step 2 has not moved.
PixelMargin of the stack (when its Margin has Y or Y2), plus the PixelMargin of the texts on the facing sides (MarginY2 of the upper one, MarginY of the lower one). On a text, MarginX / MarginX2 with PixelMargin move it away from X by that many pixels. The position of the stack itself is not used.
A child leaves the stack with stack.RemoveFromList(label): the others close up on the space it leaves when the chart draws them again. ClearList() removes all of them. A child with Visible = false stays in the stack but is left out, as one that does not fit.
One stack can hold texts that belong to different objects, for example the labels of many sessions on the right edge of the chart (AllignToRight): when a session is drawn again, remove only its labels with RemoveFromList. Keep that stack in a group which is not emptied with the sessions, such as IndVars.FrontAnnList.
The Profile chart
On the Profile chart of Deepchart the X axis has no bars: every session is a column, and each indicator draws a session in its own group. Everything in this section is desktop only. The chart lists only the indicators which allow it inRegister():
VAn.IsProfileChart tells the indicator which chart it is on. On the Profile chart it creates a group for each session it draws:
- Visible. A new group is not visible, and a group which is not visible takes no space in its session. Set
Visiblewhen itsWidthis set. - Order. The groups of the indicator in a session are placed in the order of the time given to
NewSessionAnnotationGroup, in exchange time. The X axis shows it in the local time of the chart. - Inside the group. With the default coordinates, X counts from the start of the group with the unit of the bars:
X = 1is its first column,X = Width + 1its end. - From another session. An annotation is anchored to a group with
CoordinateXType = CoordinateTypeEnum.SessionandX = session.Id | m: columnmof that group, the same asX = 1 + minside it. AsX2, theIdof the group ofXwithm0 is the end of that group. Rectangles, lines, horizontal lines and texts support it. - Under the mouse. The bar index given to
OnContextMenuis a position of the X axis:VAn.GetSessionAnnotationGroupByXIndex(barIndex)returns its group, ornull, and theReferenceExchDateTimeof the group tells which of the profiles it is.VAn.GetMainPointsCount()is the number of positions of the axis.