TICK_FLAG_BUY and TICK_FLAG_SELL simultaneously set in MqlTick structure - page 3

To add comments, please log in or register
nicholi shen
2619
nicholi shen  
douglas14:

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.

void OnStart() {
//---
   MqlTick ticks[];
   int size = CopyTicks(_Symbol, ticks, COPY_TICKS_TRADE, TimeCurrent() - 60, 1000);
   double net_volume = 0.0;
   if (size > 0) {
      for (int i=0; i<size; i++) {
         MqlTick t = ticks[i];
         if ((t.flags & TICK_FLAG_BUY) == TICK_FLAG_BUY) {
            net_volume += t.volume_real;
         }
         else if ((t.flags & TICK_FLAG_SELL) == TICK_FLAG_SELL) {
            net_volume -= t.volume_real;
         }
      }
   }
   Print(string(net_volume));
}
123
To add comments, please log in or register