Your interpretation is correct. The "Buy/Sell" tick means undefined direction :
Green circles appear when the direction of the transaction is undefined. It is used when the exchange does not transmit the direction of a transaction. In this case, the direction is determined based on the price of the transaction as compared to prices bid and ask. A Buy transaction is that executed at the ask price or above, a Sell transaction is executed at the bid price or lower. The direction is undefined if the price of the transaction is between the bid and the ask.
However like you, I don't know why a transaction can be executed between bid and ask price. This article should interested you, but it doesn't answer this issue, unless I missed it.

- www.metatrader5.com
In MetaTrader 5 thread of deals not synchronized (!). What this is mean? if you see MqlTick:
struct MqlTick { ... double bid = 3170; double ask = 3180; double last = 3175; ... };
Actually this means:
1. If flag == TICK_FLAG_BUY:
struct MqlTick { ... double bid = 3170; double ask = 3175; double last = 3175; ... };
2. If flag == TICK_FLAG_SELL:
struct MqlTick { ... double bid = 3175; double ask = 3180; double last = 3175; ... };
In MetaTrader 5 thread of deals not synchronized (!). What this is mean? if you see MqlTick:
Actually this means:
1. If flag == TICK_FLAG_BUY:
2. If flag == TICK_FLAG_SELL:
Thanks Vasiliy. But the question is some ticks have TICK_FLAG_BUY+TICK_FLAG_SELL at same time (flags:96 + 32+64) :
2017.07.25 12:20:50.000 3169.000 3170.000 3169.500 5 Buy/Sell 2017.07.25 12:20:50.000 3169.000 3170.000 3169.500 5 Buy/Sell 2017.07.25 12:20:50.000 3169.000 3170.000 3169.500 5 Buy/Sell 2017.07.25 12:20:50.000 3169.000 3170.000 3169.500 5 Buy/Sell 2017.07.25 12:20:50.000 3169.000 3170.000 3169.500 5 Buy/Sell 2017.07.25 12:20:50.000 3169.000 3170.000 3169.500 5 Buy/Sell 2017.07.25 12:20:50.000 3169.000 3170.000 3169.500 5 Buy/Sell 2017.07.25 12:20:50.000 3169.000 3170.000 3169.500 5 Buy/Sell
How is it possible ? A tick can not be a BUY and a SELL.
Thanks Vasiliy. But the question is some ticks have TICK_FLAG_BUY+TICK_FLAG_SELL at same time (flags:96 + 32+64) :
How is it possible ? A tick can not be a BUY and a SELL.
What build MetaTrader5? This is a legacy entry of ticks or it is FOREX. On true exchange TICK_FLAG_BUY+TICK_FLAG_SELL not possible combination.
Your interpretation is correct. The "Buy/Sell" tick means undefined direction :
However like you, I don't know why a transaction can be executed between bid and ask price. This article should interested you, but it doesn't answer this issue, unless I missed it.
Thank you for the article, Alain. Regardless of the buy/sell flag issue, it covers some other topics I'm interested on.
In MetaTrader 5 thread of deals not synchronized (!). What this is mean? if you see MqlTick:
Actually this means:
1. If flag == TICK_FLAG_BUY:
struct MqlTick { ... double bid = 3170; double ask = 3175; double last = 3175; ... };
2. If flag == TICK_FLAG_SELL:
struct MqlTick { ... double bid = 3175; double ask = 3180; double last = 3175; ... };
Hi, Vasiliy.
The situations you printed above never occurr in my data.
I checked more than 1 million ticks and confirmed that:
- "Buy" ticks ALWAYS have last = ask
- "Sell" ticks ALWAYS have last = bid
- "Buy/Sell" ticks ALWAYS have bid < last < ask
These tick data are from the Future USDBRL exchange rate at BMF (a Brazilian derivatives market, in Sao Paulo).
I wanted my EA to measure buy and sell aggression levels as two additional indicators in its trading strategy.
Since the number of "Buy/Sell" ticks I receive is tipically between 1% and 2% of the total number of ticks, perhaps a simple and effective solution would be just to ignore them.
Thank you anyway.
Hi, Vasiliy.
The situations you printed above never occurr in my data.
I checked more than 1 million ticks and confirmed that:
- "Buy" ticks ALWAYS have last = ask
- "Sell" ticks ALWAYS have last = bid
- "Buy/Sell" ticks ALWAYS have bid < last < ask
These tick data are from the Future USDBRL exchange rate at BMF (a Brazilian derivatives market, in Sao Paulo).
I wanted my EA to measure buy and sell aggression levels as two additional indicators in its trading strategy.
Since the number of "Buy/Sell" ticks I receive is tipically between 1% and 2% of the total number of ticks, perhaps a simple and effective solution would be just to ignore them.
Thank you anyway.
Apparently, this effect of features of BMF exchange. I don't know the specifics of pricing in this market, so can't say anything:(
You have to use bitwise operators when evaluating the condition of bitmask features/booleans.
string GetTickDescription(MqlTick &tick) { string desc=StringFormat("%s.%03d ", TimeToString(tick.time),tick.time_msc%1000); //--- Checking flags bool buy_tick=((tick.flags&TICK_FLAG_BUY)==TICK_FLAG_BUY); bool sell_tick=((tick.flags&TICK_FLAG_SELL)==TICK_FLAG_SELL); bool ask_tick=((tick.flags&TICK_FLAG_ASK)==TICK_FLAG_ASK); bool bid_tick=((tick.flags&TICK_FLAG_BID)==TICK_FLAG_BID); bool last_tick=((tick.flags&TICK_FLAG_LAST)==TICK_FLAG_LAST); bool volume_tick=((tick.flags&TICK_FLAG_VOLUME)==TICK_FLAG_VOLUME); //--- Checking trading flags in a tick first if(buy_tick || sell_tick) { //--- Forming an output for the trading tick desc=desc+(buy_tick?StringFormat("Buy Tick: Last=%G Volume=%d ",tick.last,tick.volume):""); desc=desc+(sell_tick?StringFormat("Sell Tick: Last=%G Volume=%d ",tick.last,tick.volume):""); desc=desc+(ask_tick?StringFormat("Ask=%G ",tick.ask):""); desc=desc+(bid_tick?StringFormat("Bid=%G ",tick.ask):""); desc=desc+"(Trade tick)"; } else { //--- Form a different output for an info tick desc=desc+(ask_tick?StringFormat("Ask=%G ",tick.ask):""); desc=desc+(bid_tick?StringFormat("Bid=%G ",tick.ask):""); desc=desc+(last_tick?StringFormat("Last=%G ",tick.last):""); desc=desc+(volume_tick?StringFormat("Volume=%d ",tick.volume):""); desc=desc+"(Info tick)"; } //--- Returning tick description return desc; }
You have to use bitwise operators when evaluating the condition of bitmask features/booleans.
Hi Nicolishen.
I did it correctly. The flags BUY and SELL are really simultaneously set.
This value 96 = 32 + 64 = TICK_FLAG_BUY + TICK_FLAG_SELL seems to indicate that both TICK_FLAG_BUY and TICK_FLAG_SELL flags are simultaneously set.
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...
bool buy_tick=((tick.flags&TICK_FLAG_BUY)==TICK_FLAG_BUY); bool sell_tick=((tick.flags&TICK_FLAG_SELL)==TICK_FLAG_SELL); if(buy_tick && sell_tick) ...

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi all,
When I use CopyTicks(), I often get some ticks with flags = 96 in their MqlTick structure.
This value 96 = 32 + 64 = TICK_FLAG_BUY + TICK_FLAG_SELL seems to indicate that both TICK_FLAG_BUY and TICK_FLAG_SELL flags are simultaneously set.
The documentation says:
In order to check the existence of ticks with this flag combination (which seemed weird to me), I opened the MT5 screen and clicked on 'View" - "Symbols" - "Ticks", then I requested the tick data in text file format and could confirm that "Buy/Sell" ticks really exist:
I noticed that:
Do deals that are both buy and sell aggresions really exist? If yes, what kind of deals are these?
Am I missing some point on the interpretation of the MqlTick structure flags? Or my interpretation is correct and I just lack some knowledge about how the stock market works?
Could someone please enlighten me?
Thank you,
Heraldo