Is the glass half full or half empty - how do you analyse the glass and apply it in trading? - page 4

 
Alexey Kozitsyn:

And a strategy can be implemented. A kind of "frontrunning" is possible.

I don't want to say anything about strategy - I don't know about them yet. The glass is convenient for position set and position discharge, but in the current standard glass you cannot see the price of your position, which is very uncomfortable, it is not even clear why such an obvious need has not been implemented.

 
Alexey Kozitsyn:

If you can do it all down to the lines, you can do the lines too.

Where else to find such a handyman...

 
Aleksey Vyazmikin:

Where else to find such a handyman...

You can find one, but why? To write everything else for the sake of a line in the glass?

 
Alexey Kozitsyn:

A handyman can be found, but why? For the sake of a line in the glass to write everything else?

Marking levels is very important. But, it is quite possible to simply make an indication, and put the lines on the chart and take the levels from there.

 

Hi there, trying to optimise the data representation in the glass, after creating a separate post the local clowns have spammed the topic without allowing it to develop, maybe it will be useful to someone here. Here's a topic with an arbitrary indicator.

https://www.mql5.com/ru/forum/231011

The idea is to choose the information that can be used for forecasting from all fast-changing and fake levels in the cup. I do this by applying arbitrary weights / ordinal numbers to each level.

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1

#property indicator_label1 "Delta"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrBlack
#property indicator_width1 1

int iStart;
double iDelta[];

void OnDeinit(const int reason)
{
  string symbol = Symbol();

  MarketBookRelease(symbol);
}

void OnInit()
{
  string symbol = Symbol();

  SetIndexBuffer(0, iDelta, INDICATOR_DATA);
  ArraySetAsSeries(iDelta, true);

  IndicatorSetString(INDICATOR_SHORTNAME, "OrderBook");
  IndicatorSetInteger(INDICATOR_DIGITS, Digits());

  MarketBookAdd(symbol);
}

int OnCalculate(
  const int bars,
  const int counted,
  const datetime& time[],
  const double& open[],
  const double& high[],
  const double& low[],
  const double& close[],
  const long& ticks[],
  const long& volume[],
  const int& spread[]
)
{
  if (iStart == 0)
  {
    iStart = 1;
    ZeroMemory(iDelta);
  }
  else if (bars != counted)
  {
    iDelta[0] = iDelta[1];
  }

  string symbol = Symbol();

  double ask = SymbolInfoDouble(symbol, SYMBOL_ASK);
  double bid = SymbolInfoDouble(symbol, SYMBOL_BID);

  MqlBookInfo levels[];

  bool book = MarketBookGet(symbol, levels);

  int indexBuy = 1;
  int indexSell = 1;
  long volumeBuy = 0;
  long volumeSell = 0;

  if (book)
  {
    int size = ArraySize(levels);

    for (int k = 0; k < size; k++)
    {
      if (levels[k].price >= ask) 
      {
        volumeSell += indexSell * levels[k].volume;
        indexSell++;
      }
    }

    for (int k = size - 1; k >= 0; k--)
    {
      if (levels[k].price <= bid) 
      {
        volumeBuy += indexBuy * levels[k].volume;
        indexBuy++;
      }
    }
  }

  iDelta[0] = (double) (volumeBuy - volumeSell);
  
  return bars;
}
 
Andy Sanders:

Not a good implementation.

1. beeches are better received in a dedicated function, otherwise you will get skips.

2. Yes, you may quit the loops earlier. You will have to perform 20 extra checks in each one.

Concerning the idea - please explain what does it give you? What does your indicator do? How does it help to identify "non-fake" levels?

 
Alexey Kozitsyn: Regarding the idea - please explain what it does? What does your indicator do? How does it help to highlight "non-fake" levels?

thanks for the comment, I will optimise it later
the tumblers I have seen look about the same, two walls on each side of the spread, and between them some volumes


1. fat fast-changing levels around the spread
2. [#2 in the picture] further there is a wall with medium volume, but which may hold a sharp fall upwards, an order cannot be placed behind this wall because if the movement is gradual, it will start to move
3. [at the very edges is some kind of a dragon volume, which seems to be able to withstand any kind of trend, but in fact it will also start to move when we have a gradual move.
4. Most likely, between #1 and #2 are the volumes of robots who are trying to use the wall somehow and as the wall moves, these levels change synchronously.

The first idea that comes to mind to analyze these levels is that if the total volume at the top is greater, it means that the market maker demonstrates its intention to sell and move the market downwards, the demand is greater, respectively, and vice versa. But this assumption is not entirely accurate, because.

1. the position of those walls is changing and we cannot rely on them as support or resistance, that is why we cannot consider those dragon volumes as Open Interest as well, those orders will most probably never be filled and will move so we should somehow exclude the fake walls from the Open Interest analysis
2. At the same time the movement is usually initiated by market orders and starts around the spread, moreover for the robots it is risky to play with fake orders around the spread, they may also get executed, hence the assumption, that the most real market intentions can be seen only at orders around the spread, if the order is placed, they want it to be filled but against the background of the fake walls these movements might be unnoticeable, one more reason to remove from the cup pseudo-large volumes standing far from the spread

Considering the above, we can't just discard pseudo-walls because we don't have a clear definition where a pseudo-wall is and where a big order is, so we just assign weights to the cup's weights to pay attention only to the movement around the spread.

Цена | Обьем - Стандартный стакан

20    | 5
20.5  | 200
30    | 10
30.5  | 5
40    | 20
40.5  | 1         Итого: 241 контрактов на покупку

50

50.5  | 1
60    | 40
60.5  | 10
70    | 50
70.5  | 100
80    | 5         Итого: 206 контрактов на покупку
In other words, just by adding up the volumes we think that there are a lot of sellers, but those 200 sellers from the top will never sell anything...
But when we match the orders before the walls, the buyers will be ahead of the buyers.
Let's try to use scales.
Цена | Обьем - Реалистичный стакан

20    | 5     х 1
20.5  | 200   х 2
30    | 10    х 3
30.5  | 5     х 4
40    | 20    х 5
40.5  | 1     х 6         Итого: 561 контрактов на покупку

50

50.5  | 1     х 6
60    | 40    х 5
60.5  | 10    х 4
70    | 50    х 3
70.5  | 100   х 2
80    | 5     х 1        Итого: 601 контрактов на покупку
This is more realistic. Perhaps weights should not be linear, but geometrical in progression, then we will see better. Also, we want to see the dependence of price changes on the stack data, that is why correct adding of weights allows us to see how the price changes depending on the state of the stack on a certain bar
 
Andy Sanders:


So, just adding up the volumes we think that there are a lot of sellers, but those 200 sellers from the top will never sell anything.
And when we match the orders before the walls, the buyers will be ahead of the buyers.
Let's try to use scales.
This is more realistic. Perhaps weights should not be linear, but geometrical in progression, in this case we will see better. Also, we want to see the dependence of price changes on the stack data, that is why correct adding of weights allows us to see how the price changes depending on the state of the stack on a certain bar

This is an interesting idea. But, you have to take into account that bigwigs use iceberg bids, i.e. the ones that refill themselves in case they try to get eaten. And what is the depth of the glass at which the levels are hung - 6 on either side?

 
Aleksey Vyazmikin:

This is an interesting idea. But, you have to take into account that bigwigs use iceberg bids, i.e. the ones that refill themselves in case they try to get eaten. And what is the depth of the glass at which the levels are hung - 6 on either side?

I've just realised that it's now done a little wrong.
There is now a cycle from the edge of the cup to the spread, the order number of the iteration is the weight.
In this case, if volumes are small, but levels are numerous, we will obtain huge weights near the spread.

Therefore it is necessary, on the contrary, to set the number of analyzed levels, for example, 10 on each side and the maximum weight, and start placing weights from the spread, rather than from the edges, closer to the edges weights will decrease, up to zero. In that case, it will be more correct to analyse the price movement by +- 10 pips, no matter how many levels were set.

How to get rid of icebergs - I don't know, in theory, they will be equal on both sides, so they should not affect the analysis.

 
Andy Sanders:

The idea is clear, thank you. And why not just look from which level high volume (> X lots) is not removed for some period of time (> Y cup updates) in order to find "walls"? And mark that point on the chart with a dot?

This immediately filters out robots that drag large volumes back and forth, as they don't stay in one place for long.

It may look like this:

Each point is a level of at least 500 lots with a duration of at least 150 cup updates.