TICK_FLAG_BUY / TICK_FLAG_SELL - CopyTicks() and SymbolInfoTick() difference

 

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:

//+------------------------------------------------------------------+
//| ON CALCULATE
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime& time[],
                const double& open[],
                const double& high[],
                const double& low[],
                const double& close[],
                const long& tick_volume[],
                const long& volume[],
                const int& spread[]) {

    // gets just executed tick for the Symbol...
    if (!SymbolInfoTick( _Symbol, curTick ))  { Print("Tick NOT received!"); return 0; }

    //DEBUG:
    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 );

    // adds up the BUY/SELL volume...
    if      ((curTick.flags &TICK_FLAG_BUY)==TICK_FLAG_BUY)    { bufferBUY[0]  += curTick.volume_real; }
    else if ((curTick.flags &TICK_FLAG_SELL)==TICK_FLAG_SELL)  { bufferSELL[0] -= curTick.volume_real; }

    return rates_total;
}
 

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...

;)

 
Flavio Jarabeck:

I'm still trying to find why on earth I'm receving a ZERO flag (with real volume and price) as a valid tick...

;)

It may be the directs trade.
 
There is another topic about this, too lazy to look it up. But some Brokers under strict terms i assume are allowed by exchange to match trades internally, however because the central market, it is still required to make the deal public and thus send back to the exchange (B3). Maybe this ZERO flag tick is such an event.
 

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.