Skip to main content
Source: src/Deepdom/Book/BookImbalance.cs The share of the order book which is on the bid side, over the first levels of each side: a line in an area of its own and a label on the chart.

What it shows

  • OnBook and the updates of the book.
  • FullIniDepth, the book at the first bar of the chart.
  • LiquiditySumHelper.
  • A label with relative coordinates, drawn on the foreground.

How it works

The helper sums the first Levels levels of each side. It is created in OnLoad, and the first OnBook applies the initial snapshot before the updates:
Draw writes the point of the current bar and the label:

Things to notice

  • The point is written with BookIndex: the book belongs to the bar being built, see Two indices.
  • The label uses relative coordinates (0.02, 0.95) and a group with PlotForeground = true: it stays at the top left, over the bars.
  • FullIniDepth is read from the first OnBook, not from OnLoad: it is empty before the bars start.

Try

  • Draw the two sums as two series instead of the share.
  • Add a parameter to count the levels within a number of ticks from the best price instead of a fixed number of levels.