TICK_FLAG_BUY / TICK_FLAG_SELL - CopyTicks() and SymbolInfoTick() difference
As bizarre as it is...
I found a way to identify, at least for the brazilian B3 exchange, the BUY and SELL ticks from SymbolInfoTick()...
I will leave the code here to help others...
Cheers!
OnCalculate() code:
// gets just executed tick for the Symbol... if (!SymbolInfoTick( _Symbol, curTick )) { Print("Tick NOT received!"); return 0; } /* //DEBUG: TICK_FLAG_BID | TICK_FLAG_ASK = 6 // TICK_FLAG_LAST | TICK_FLAG_VOLUME = 24 // BUY=56 / SELL=88 -->TICK_FLAG_LAST+TICK_FLAG_VOLUME+TICK_FLAG_BUY,idem string o = TimeToString(curTick.time) + " bid: " + (string)curTick.bid + " ask:" + (string)curTick.ask + " last: " + (string)curTick.last + " vol:" + (string)curTick.volume_real; if ((curTick.flags &TICK_FLAG_BID)==TICK_FLAG_BID) { o += " -BID- " + (string)curTick.flags; } else if ((curTick.flags &TICK_FLAG_ASK)==TICK_FLAG_ASK) { o += " -ASK- " + (string)curTick.flags; } else if ((curTick.flags &TICK_FLAG_LAST)==TICK_FLAG_LAST) { o += " -LAST- " + (string)curTick.flags; } else if ((curTick.flags &TICK_FLAG_BUY)==TICK_FLAG_BUY) { o += " -BUY- " + (string)curTick.flags; } else if ((curTick.flags &TICK_FLAG_SELL)==TICK_FLAG_SELL) { o += " -SELL- " + (string)curTick.flags; } else if ((curTick.flags &TICK_FLAG_VOLUME)==TICK_FLAG_VOLUME) { o += " -VOLUME- " + (string)curTick.flags; } else { o += " -UNKNOWN- " + (string)curTick.flags; } Print( o ); */ if (curTick.flags == TICK_FLAG_LAST+TICK_FLAG_VOLUME+TICK_FLAG_BUY) { bufferBUY[0] +=curTick.volume_real; } else if (curTick.flags == TICK_FLAG_LAST+TICK_FLAG_VOLUME+TICK_FLAG_SELL) { bufferSELL[0] -=curTick.volume_real; }
I'm still trying to find why on earth I'm receving a ZERO flag (with real volume and price) as a valid tick...
;)
I'm still trying to find why on earth I'm receving a ZERO flag (with real volume and price) as a valid tick...
;)
I think you need to check first if the flag is BUY and SELL at the same time.
I'm using this kind of code below:
MqlTick tick_array[]; int copied = CopyTicks(_Symbol,tick_array,COPY_TICKS_TRADE,0,2000); ArraySetAsSeries(tick_array,true); //--- ## for looping ##--- MqlTick tick = tick_array[i]; bool auction = tick.bid > tick.ask; long time = tick.time_msc; if(time!=last) // Same DEAL Agression { last=time; if(( tick.flags&TICK_FLAG_BUY)==TICK_FLAG_BUY && ( tick.flags&TICK_FLAG_SELL)==TICK_FLAG_SELL) { continue; } else if(( tick.flags&TICK_FLAG_BUY)==TICK_FLAG_BUY) // In case of a buy tick { BuyV=(long)tick.volume; SellV=0; } else if(( tick.flags&TICK_FLAG_SELL)==TICK_FLAG_SELL) // In case of a sell tick { SellV=(long)tick.volume; BuyV=0; } } else // Several DEALS Agression { if(( tick.flags&TICK_FLAG_BUY)==TICK_FLAG_BUY && ( tick.flags&TICK_FLAG_SELL)==TICK_FLAG_SELL) { continue; } else if(( tick.flags&TICK_FLAG_BUY)==TICK_FLAG_BUY) // In case of a buy tick { BuyV = BuyV+(long)tick.volume; SellV=0; } else if(( tick.flags&TICK_FLAG_SELL)==TICK_FLAG_SELL) // In case of a sell tick { SellV = SellV+(long)tick.volume; BuyV=0; } }
I think this kind of situation must be count as just 1 agression and the volume should be summed.

While CopyTicks() give me the TICK_FLAG_BUY / TICK_FLAG_SELL flags, SymbolInfoTick() does not.
Market: Brazil / B3 exchange / Futures / Broker: Modal
With SymbolInfoTick() I only get BID/ASK/LAST flags... and an "unknown" flag (0=zero).
Is this behavior correct?
And, is this Zero flag expected from SymbolInfoTick()? what is it?
Thanks for any light!
;)
Testing Code: