Testing 'CopyTicks' - page 17

 
fxsaber:
Is tick bar volume a rudiment? An indicator which, in principle, means nothing on the exchange. You cannot use it consciously. It is rubbish.

Well actually, the tick volume on the stock exchange is the number of flippers. That is, the actual number of trades.

 
Slawa:

Well actually, the tick volume on the stock exchange is the number of flippers. That is, the actual number of trades.

So the bar does not change when a trade comes in that is completely identical to the previous one.
 
fxsaber:
So the bar does not change when a trade comes in that is completely identical to the previous one.
Tick and real volumes change
 
The Expert Advisor writes fresh history ticks and reveals the N-third bug in CopyTicks
#include <TypeToBytes.mqh> // https://www.mql5.com/ru/code/16280

string GetTickFlag( uint tickflag )
{
  string flag = "";

#define  TICKFLAG_MACRO(A) flag += ((bool)(tickflag & TICK_FLAG_##A)) ? " TICK_FLAG_" + #A : "";
  TICKFLAG_MACRO(BID)
  TICKFLAG_MACRO(ASK)
  TICKFLAG_MACRO(LAST)
  TICKFLAG_MACRO(VOLUME)
  TICKFLAG_MACRO(BUY)
  TICKFLAG_MACRO(SELL)
#undef  TICKFLAG_MACRO

  if (flag == "")
    flag = " FLAG_UNKNOWN (" + (string)tickflag + ")";
     
  return(flag);
}

#define  TOSTRING(A) " " + #A + " = " + (string)Tick.A

string TickToString( const MqlTick &Tick )
{
  return(TOSTRING(time) + "." + (string)(Tick.time_msc %1000) +
         TOSTRING(bid) + TOSTRING(ask) + TOSTRING(last)+ TOSTRING(volume) + GetTickFlag(Tick.flags));
}

#define  TOSTRING2(A) #A + " = " + (string)A

int AddFreshTicks( MqlTick &Ticks[], const string Symb = NULL, const uint flags = COPY_TICKS_ALL )
{
  int Res = 0;
  const int Amount = ArraySize(Ticks);
  
  MqlTick NewTicks[];  
  const int NewAmount = (Amount == 0) ? CopyTicks((Symb == NULL)? Symbol() : Symb, NewTicks, flags) :
                                        CopyTicks((Symb == NULL)? Symbol() : Symb, NewTicks, flags, Ticks[Amount - 1].time_msc);
  
  if (NewAmount > 0)
  {
    if (Amount > 0)
    {
      // Взяли крайнее время из предыдущей истории
      const long LastTime = Ticks[Amount - 1].time_msc;
      
      int Count = 1;
      
      // Находим (Count) в предыдушей истории количество тиков со временем LastTime
      for (int i = Amount - 2; i >= 0; i--)
      {
        if (Ticks[i].time_msc < LastTime)
          break;
          
        Count++;
      }

      if ((Count < Amount) && (Count < NewAmount))      
      {
        // Если Count-тик c LastTime-временем в новой истории не равен самому последнего тику в старой истории, выводим в журнал
        if (_R(Ticks[Amount - 1]) != NewTicks[Count - 1]) // https://www.mql5.com/ru/code/16280
          Print(TOSTRING2(TickToString(Ticks[Amount - 1])) + "\n" +
                TOSTRING2(TickToString(NewTicks[Count - 1])) + "\n" + TOSTRING2(TickToString(NewTicks[Count])) + "\n");              

        Res = ArrayCopy(Ticks, NewTicks, Amount, Count);
      }
    }
    else
      Res = ArrayCopy(Ticks, NewTicks);
  }
  
  return(Res);
}

void OnTick( void )
{
  static MqlTick PrevTicks[];
  
  // Дописываем свежие тики
  AddFreshTicks(PrevTicks);
}

This time I wrote detailed comments, so the result should be clear

2016.09.22 12:20:03.762 Test8 (RTS-12.16,M1)    TickToString(NewTicks[Count]) =  time = 2016.09.22 12:19:53.233 bid = 0.0 ask = 0.0 last = 98560.0 volume = 1 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_BUY
2016.09.22 12:20:03.762 Test8 (RTS-12.16,M1)    TickToString(NewTicks[Count-1]) =  time = 2016.09.22 12:19:51.968 bid = 0.0 ask = 0.0 last = 98550.0 volume = 1 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_SELL
2016.09.22 12:20:03.762 Test8 (RTS-12.16,M1)    TickToString(Ticks[Amount-1]) =  time = 2016.09.22 12:19:51.968 bid = 98550.0 ask = 0.0 last = 98550.0 volume = 1 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_SELL
2016.09.22 12:20:02.504 Test8 (RTS-12.16,M1)    
2016.09.22 12:20:02.504 Test8 (RTS-12.16,M1)    TickToString(NewTicks[Count]) =  time = 2016.09.22 12:19:51.968 bid = 98550.0 ask = 0.0 last = 98550.0 volume = 1 TICK_FLAG_LAST TICK_FLAG_VOLUME TICK_FLAG_SELL
2016.09.22 12:20:02.504 Test8 (RTS-12.16,M1)    TickToString(NewTicks[Count-1]) =  time = 2016.09.22 12:19:51.813 bid = 98550.0 ask = 0.0 last = 0.0 volume = 0 TICK_FLAG_BID
2016.09.22 12:20:02.504 Test8 (RTS-12.16,M1)    TickToString(Ticks[Amount-1]) =  time = 2016.09.22 12:19:51.813 bid = 98550.0 ask = 98560.0 last = 0.0 volume = 0 TICK_FLAG_BID
The problem is not only with COPY_TICKS_ALL but also with other modes (LAST, INFO).
 
fxsaber:
The Expert Advisor has completed writing of fresh history ticks and has found the ninth bug in CopyTicks.

This time I wrote detailed comments, so the result should be clear

The problem affects not only the COPY_TICKS_ALL, but also other modes (LAST, INFO).

Tried to add ticks via From == 0. Doesn't work! - Bugs in CopyTicks.

Dear developers, I need this function (to add a new history data) very much. Let it be retarded for now, but it will work. Please write here its working version.

You will have to fix bugs in CopyTicks for a long time and not one build. How others use CopyTicks - I cannot understand. Apparently, they do not use them at all. They lack imagination.

 

You would state clearly what exactly you consider to be a bug.

 
Renat Fatkhullin:

You would state clearly what exactly you consider to be a bug.

Responded very clearly in code. Created an application to Service Desk, where I wrote out even more details.
 
fxsaber:
Answered this question very clearly by the code. I have made an request to Service Desk where I have described everything in details.

The error lies in the fact that in the newly obtained tick array the first entries contain zero bid, ask or last. whereas in the previous array the same ticks at the end of the array do not contain zeros, but contain the then current values of bid, ask and last

This error in CopyTicks was fixed after the build was released. Now the initial ticks entries after the call of CopyTicks will contain not zeros, but current values of bid, ask and last at the requested moment of time.

Unfortunately, the fixes were not included in the current build.

 
Slawa:

The error consists in the fact that in the newly obtained tick array the first entries contain zero bid, ask or last values, while in the previous array the same ticks at the end of the array do not contain zeros, but contain the current values of bid, ask and last

This bug in CopyTicks was fixed already after the build was released. Now the initial ticks records after the call of CopyTicks will contain not zeros, but the current values of bid, ask and last at the requested time

I do not understand you. You are saying that you have your own internal format of history storing. And CopyTicks takes a piece of it at each request and generates its own sequence of MqlTick? The same flags are calculated by CopyTicks, and they aren't stored in the history? Some pad, which also calculates something, and not just converts it into usable format.

I don't need CopyTicks to fill something there, depending on the time of the request. I just want to get the history without any distortions. And add it without any problems.

Unfortunately, there are no fixes in current build.

Please release the beta build on your server. I'm sure I'll find more inconsistencies. Let's lick this CopyTicks so that it can finally be trusted!

 
fxsaber:
The Expert Advisor completes the fresh historical ticks and detects the N-th CopyTicks bug
If you need ONLY ribbon (COPY_TICKS_TRADE - time_msc, last, volume and flags), then this solution is completely suitable - no bugs detected.