# 8. Orders and trades indicator

I have come up with an idea to combine open orders and trades at the market price to create a leading indicator for forecasting market movement.

Open orders are represented in a table called “market depth”. Its fragment is shown in Fig. 8.1. The table contains bid, ask, volume of buy and sell open orders in lots.

Trades at market price are represented in a table called “anonymous trades”. Its fragment is shown in Fig. 8.2. The table contains time of the trade, security tag, volume of the trade in lots, direction of the trade (buy or sell). This table may also contain other data, for example, bid and ask, but we do not need them.

The program accesses the market depth table and calculates the total volume separately of all buy and sell open orders at the end of each minute during the trading day. These volumes are displayed as a blue and red line under the 1-minute price chart in Fig. 8.3 for buyers and sellers respectively. If the blue line lies above the red, then there are more buy orders, and vice versa. In some cases, the indicator correctly warns of a price reversal: buy (sell) orders prevail before the market rises (falls). As can be seen in Fig. 8.3, usually soon after an increase in the volume of buy orders, the price rises, and after an increase in the volume of sell orders the price drops.

The program also refers to the table of anonymous trades and calculates the total volume separately of all buy and sell trades for every minute during the trading day (the sum of these volumes is the volume displayed by the standard volume indicator). These volumes are displayed as blue and red dots in Fig. 8.3. A large volume of buy or sell trades often leads to a large candle.

Now we can evaluate the strength of the bulls and bears S as:
S=BO+BT-SO-ST
where
BO- volume of buy open orders
SO- volume of sell open orders

Bulls dominate when S>0, and bears dominate if S<0. Blue and red triangles in Fig. 8.3. correspond to the dominance of bulls and bears, respectively.

Now let's decide when the bulls and bears lose their strength. To do this, we register every minute when the volume of buy and sell orders at the end of the current minute drops compared to the end of the previous minute during the trading day. If this drop is greater than the volume of trades of the opposite sign for the current minute, then some orders were canceled during this minute. Canceled buy (sell) orders mean that buyers (sellers) are leaving, and the price often changes after some time in favor of those who remain. I call this phenomenon the pessimism of bulls and bears, which can be defined as:
PBi = BOi - BOi-1 + STi
PSi = SOi -SOi-1 + BTi
where
PBi - bull pessimism measure
PSi - bear pessimism measure
BOi and BOi-1 - volume of buy open orders at minute i and i-1
SOi and SOi-1 - volume of sell open orders at minute i and i-1