TICK_FLAG_BUY and TICK_FLAG_SELL simultaneously set in MqlTick structure - page 2

 

I talked to a person who does not know Metatrader but knows very well the BMF market and he gave me an explanation that i would like to share with you.

He said that there are 3 kinds of trades at BMF:

  • BUY trades - a buyer sends a buy market order that closes someone's sell limit order
  • SELL trades - a seller sends a sell market order that closes someone's buy limit order
  • DIRECT trades - a buyer and a seller send buy and sell market orders simultaneously through the same broker and that broker deals the trade directly between them, without closing any limit order at the market.

He explained me that the broker is authorized to make direct deals between its own customers, as long as the transaction price is inside the market spread range (higher than the current bid price and lower than the current ask price) and the trade information is sent to the market. He told me direct deals are regularly recorded as any other trade (so they must generate tick data records as well).

I told him that the "Buy/Sell" records are around 1% of the total market volume and he thinks it looks a plausible figure for the volume share of direct deals at BMF.

So, it seems that the mistery of the "Buy/Sell" ticks at BMF is solved.

I am curious to know if the markets in other countries also have that kind of direct trade, or if it is just a "Brazilian weirdness".

Regards!


 
nicholishen:

Hi Heraldo,

This is not how you evaluate a bitmask.  You could be right some of the time, but those flags could also be set with other flags as well - and the total will not still be 96.

You would need to do something like this instead... 


Yes, Nicolishen.

The sentence you mentioned from my post do not reflect how the flags are evaluated in my robot's code.

I was just reporting that I received ticks with flags=96 and that this was a proof that both BUY and SELL flags were simultaneously set, since 96 = 64 + 32 = 2^6 + 2^5 (bits 6 and 5 set).

The statement above has nothing to do with the evaluation of the flags in the robot's code

In my code I properly check the bit flags through bitwise logical operations, exactly as you mentioned.

Thank you anyway.



 
nicholishen:

Hi Heraldo,

This is not how you evaluate a bitmask.  You could be right some of the time, but those flags could also be set with other flags as well - and the total will not still be 96.

You would need to do something like this instead... 

That's not exact. 96 can only by bits 5 and 6 set, so 32+64.

Anyway that's really not what matters in this topic.

EDIT: I see Heraldo answer after I posted this, he said the same as expected.
 
HeraldoAlmeida:

I talked to a person who does not know Metatrader but knows very well the BMF market and he gave me an explanation that i would like to share with you.

He said that there are 3 kinds of trades at BMF:

  • BUY trades - a buyer sends a buy market order that closes someone's sell limit order
  • SELL trades - a seller sends a sell market order that closes someone's buy limit order
  • DIRECT trades - a buyer and a seller send buy and sell market orders simultaneously through the same broker and that broker deals the trade directly between them, without closing any limit order at the market.

He explained me that the broker is authorized to make direct deals between its own customers, as long as the transaction price is inside the market spread range (higher than the current bid price and lower than the current ask price) and the trade information is sent to the market. He told me direct deals are regularly recorded as any other trade (so they must generate tick data records as well).

I told him that the "Buy/Sell" records are around 1% of the total market volume and he thinks it looks a plausible figure for the volume share of direct deals at BMF.

So, it seems that the mistery of the "Buy/Sell" ticks at BMF is solved.

I am curious to know if the markets in other countries also have that kind of direct trade, or if it is just a "Brazilian weirdness".

Regards!


Very interesting. Thank you very much for sharing.
 
Alain Verleyen:

That's not exact. 96 can only by bits 5 and 6 set, so 32+64.

Anyway that's really not what matters in this topic.

EDIT: I see Heraldo answer after I posted this, he said the same as expected.

The point I was making was that Heraldo will be missing data when (for example) 

flags = TICK_FLAG_BUY|TICK_FLAG_SELL|TICK_FLAG_VOLUME; 

Any other flag in combination with TICK_FLAG_BUY and TICK_FLAG_SELL will mean that (flags != 96) despite buy and sell flags being set true.


Edit: Yes, I just saw his reply as well. No worries Heraldo.

 
nicholishen:

The point I was making was that Heraldo will be missing data when (for example) 

Any other flag in combination with TICK_FLAG_BUY and TICK_FLAG_SELL will mean that (flags != 96) despite buy and sell flags being set true.


Edit: Yes, I just saw his reply as well. No worries Heraldo.

Sure we agree on that. Sorry for the misunderstanding.
 
Alain Verleyen:
Sure we agree on that. Sorry for the misunderstanding.

nicholishen:

The point I was making was that Heraldo will be missing data when (for example) 

Any other flag in combination with TICK_FLAG_BUY and TICK_FLAG_SELL will mean that (flags != 96) despite buy and sell flags being set true.


Edit: Yes, I just saw his reply as well. No worries Heraldo.

No worries, Nicholishen. Your intention was good. If I were checking the flags the wrong way I would benefit from your explanation. Thank you!

 
Heraldo Almeida:

I talked to a person who does not know Metatrader but knows very well the BMF market and he gave me an explanation that i would like to share with you.

He said that there are 3 kinds of trades at BMF:

  • BUY trades - a buyer sends a buy market order that closes someone's sell limit order
  • SELL trades - a seller sends a sell market order that closes someone's buy limit order
  • DIRECT trades - a buyer and a seller send buy and sell market orders simultaneously through the same broker and that broker deals the trade directly between them, without closing any limit order at the market.

He explained me that the broker is authorized to make direct deals between its own customers, as long as the transaction price is inside the market spread range (higher than the current bid price and lower than the current ask price) and the trade information is sent to the market. He told me direct deals are regularly recorded as any other trade (so they must generate tick data records as well).

I told him that the "Buy/Sell" records are around 1% of the total market volume and he thinks it looks a plausible figure for the volume share of direct deals at BMF.

So, it seems that the mistery of the "Buy/Sell" ticks at BMF is solved.

I am curious to know if the markets in other countries also have that kind of direct trade, or if it is just a "Brazilian weirdness".

Regards!


Very good. When the broker does this, it is called "Facilitation".
 
nicholi shen:

You have to use bitwise operators when evaluating the condition of bitmask features/booleans.

I am trying to do/understand exaclty this. Can you reference a article please?
 
  MqlTick ARRAY_TICKS[];
  ArraySetAsSeries(ARRAY_TICKS, false);
  int TICKS_RECEIVED=CopyTicksRange(PAPEL,ARRAY_TICKS,COPY_TICKS_TRADE,TInicial_long,TFinal_long);
  if(TICKS_RECEIVED>1)

  for(int tick = 0; tick<TICKS_RECEIVED; tick++){
   if(ARRAY_TICKS[tick].flags==TICK_FLAG_BUY){
      SOMA_COMPRAS=SOMA_COMPRAS+ARRAY_TICKS[tick].volume_real;
      entrou1="entrou1";}
   if(ARRAY_TICKS[tick].flags==TICK_FLAG_SELL){
      SOMA_VENDAS=SOMA_VENDAS+ARRAY_TICKS[tick].volume_real;      
      entrou2="entrou2";}
  
  }



The code above does not get me the sum of trades of type TICK_FLAG_BUY neither the sum of trades of type TICK_FLAG_SELL. Actually it never enters the 2 "ifs".

What is the correct way to sum the volume separated by Buys and Sells ? In a given time interval.