Testing 'CopyTicks' - page 40

 
Copytix can't get the existing tick out
struct MQLTICK
{
  uchar Data[sizeof(MqlTick)];
};

union UNION
{
  MQLTICK Tick1;
  MqlTick Tick2;  
  
  UNION()
  {
    ArrayInitialize(this.Tick1.Data, 1);
  }
};

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

void OnStart()
{  
  const string Name = "A1234";

  if (CustomSymbolCreate(Name) || SymbolInfoInteger(Name, SYMBOL_CUSTOM))
  {    
    UNION Union;
    
    MqlTick Ticks[] = {{0}};
    Ticks[0] = Union.Tick2;
    
    Ticks[0].time = TimeCurrent();
    Ticks[0].time_msc = Ticks[0].time * 1000;
    
    Print(TOSTRING(CustomTicksReplace(Name, Ticks[0].time_msc, Ticks[0].time_msc, Ticks))); // Тик записали без проблем
    
    MqlTick Ticks2[];
    
    SymbolSelect(Name, true);            
    
    // Прочесть тик не можем
    Print(TOSTRING(CopyTicksRange(Name, Ticks2)));
    Print(TOSTRING(CopyTicks(Name, Ticks2)));
    
    SymbolSelect(Name, false);            
    CustomSymbolDelete(Name);    
  }
}

Result

CustomTicksReplace(Name,Ticks[0].time_msc,Ticks[0].time_msc,Ticks) = 1
CopyTicksRange(Name,Ticks2) = 0
CopyTicks(Name,Ticks2) = 0
 

Copytix changes the raw data

struct MQLTICK
{
  uchar Data[sizeof(MqlTick)];
};

union UNION
{
  MQLTICK Tick1;
  MqlTick Tick2;  
  
  UNION()
  {
    ArrayInitialize(this.Tick1.Data, 1);
  }
};

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

void OnStart()
{  
  const string Name = "A1234";

  if (CustomSymbolCreate(Name) || SymbolInfoInteger(Name, SYMBOL_CUSTOM))
  {    
    UNION Union;
    
    MqlTick Ticks[] = {{0}};
    Ticks[0] = Union.Tick2;
    
    Ticks[0].time = 0;
    Ticks[0].time_msc = 0;

    Print(TOSTRING(Ticks[0].ask));
    
    Print(TOSTRING(CustomTicksReplace(Name, Ticks[0].time_msc, Ticks[0].time_msc, Ticks)));
    
    MqlTick Ticks2[];
    
    SymbolSelect(Name, true);            
    
    // Прочесть тик не можем
    Print(TOSTRING(CopyTicksRange(Name, Ticks2)));

    Print(TOSTRING(Ticks2[0].ask));
    
    SymbolSelect(Name, false);            
    CustomSymbolDelete(Name);    
  }
}


Result

Ticks[0].ask = 7.748604185489348 e-304
CustomTicksReplace(Name,Ticks[0].time_msc,Ticks[0].time_msc,Ticks) = 1
CopyTicksRange(Name,Ticks2) = 1
Ticks2[0].ask = 0.0
 

Why are unnecessary tics being generated?


The script outputs excessive ticks

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)IntegerToString(Tick.time_msc %1000, 3, '0') +
         TOSTRING(bid) + TOSTRING(ask) + TOSTRING(last)+ TOSTRING(volume) + GetTickFlag(Tick.flags));
}

struct MQLTICK : public MqlTick
{
  bool operator ==( const MqlTick &Tick ) const
  {
    return((!Tick.ask || (Tick.ask == this.ask)) &&
           (!Tick.bid || (Tick.bid == this.bid)));
  }
  
  void operator =( const MqlTick &Tick )
  {
    this.ask = Tick.ask ? Tick.ask : this.ask;
    this.bid = Tick.bid ? Tick.bid : this.bid;
  }
};

void OnStart()
{
  MqlTick Ticks[];
  const int Amount = CopyTicks(_Symbol, Ticks, COPY_TICKS_ALL, 0, 1 e4);

  MQLTICK Tick = {0};  
  
  for (int i = 0; i < Amount; i++)
    if (Tick == Ticks[i])
      Print(TickToString(Ticks[i]));
    else
      Tick = Ticks[i];
}


Result on EURUSD Metaquotes-Demo

 time = 2017.11.14 02:27:14.352 bid = 1.16679 ask = 1.16682 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 02:29:11.325 bid = 1.16685 ask = 1.16687 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 03:04:02.402 bid = 1.16715 ask = 1.16717 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 03:41:09.453 bid = 1.16707 ask = 1.1671 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 03:42:53.101 bid = 1.16718 ask = 1.16721 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 04:51:22.072 bid = 1.16719 ask = 1.16721 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 04:53:55.649 bid = 1.16714 ask = 1.16717 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 04:56:12.254 bid = 1.16713 ask = 1.16716 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 04:57:12.497 bid = 1.16713 ask = 1.16716 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 04:58:28.934 bid = 1.16719 ask = 1.16722 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 05:18:44.717 bid = 1.16728 ask = 1.16731 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 05:25:39.559 bid = 1.16725 ask = 1.16728 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 05:27:54.243 bid = 1.16718 ask = 1.1672 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 05:29:38.909 bid = 1.16718 ask = 1.1672 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 05:31:40.868 bid = 1.16719 ask = 1.1672 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 05:38:29.393 bid = 1.16709 ask = 1.16712 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 05:39:29.429 bid = 1.16709 ask = 1.16712 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 05:47:36.539 bid = 1.16718 ask = 1.1672 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 06:19:44.287 bid = 1.16726 ask = 1.16729 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 06:21:11.941 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 06:22:22.686 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 06:23:11.019 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 06:23:24.926 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 06:24:22.060 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 06:24:26.871 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 06:25:26.704 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 06:25:27.401 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 06:42:16.087 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 06:44:00.557 bid = 1.16734 ask = 1.16737 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 06:44:36.362 bid = 1.16734 ask = 1.16737 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 06:45:00.577 bid = 1.16734 ask = 1.16737 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 06:51:36.472 bid = 1.16734 ask = 1.16737 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 06:52:37.091 bid = 1.16734 ask = 1.16737 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 06:53:38.025 bid = 1.16734 ask = 1.16737 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 06:56:11.389 bid = 1.16729 ask = 1.16732 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 07:03:22.022 bid = 1.16708 ask = 1.16711 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 07:08:35.305 bid = 1.16718 ask = 1.16721 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 07:24:15.039 bid = 1.16755 ask = 1.16758 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 07:27:16.339 bid = 1.16751 ask = 1.16754 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 07:39:26.342 bid = 1.16739 ask = 1.16742 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 07:43:33.909 bid = 1.16744 ask = 1.16747 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 07:45:25.462 bid = 1.16744 ask = 1.16747 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 07:47:05.824 bid = 1.16741 ask = 1.16744 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 07:48:19.985 bid = 1.16744 ask = 1.16747 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 07:49:57.642 bid = 1.16744 ask = 1.16747 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 07:52:39.036 bid = 1.16738 ask = 1.16741 last = 0.0 volume = 0 TICK_FLAG_ASK
 time = 2017.11.14 08:04:47.750 bid = 1.16739 ask = 1.16741 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 08:23:23.778 bid = 1.16705 ask = 1.16707 last = 0.0 volume = 0 TICK_FLAG_BID TICK_FLAG_ASK
 time = 2017.11.14 08:28:22.233 bid = 1.16706 ask = 1.16708 last = 0.0 volume = 0 TICK_FLAG_BID
 time = 2017.11.14 08:28:37.245 bid = 1.16706 ask = 1.16708 last = 0.0 volume = 0 TICK_FLAG_ASK
 

Copitix in COPY_TICKS_ALL mode is amateurishly filling in zero Bid/Ask fields.

void OnStart()
{
  MqlTick Ticks[];
  const int Amount = CopyTicks(_Symbol, Ticks);
  
  ArrayPrint(Ticks);
}
[1986] 2017.11.14 10:12:11 1.16873 1.16873 0.0000        0 1510654331879       6
[1987] 2017.11.14 10:12:12 1.16871 1.16873 0.0000        0 1510654332026       2
[1988] 2017.11.14 10:12:12 1.16871 1.16871 0.0000        0 1510654332947       4
[1989] 2017.11.14 10:12:16 1.16869 1.16870 0.0000        0 1510654336930       6
[1990] 2017.11.14 10:12:17 1.16867 1.16868 0.0000        0 1510654337028       6
[1991] 2017.11.14 10:12:20 1.16866 1.16868 0.0000        0 1510654340943       2
[1992] 2017.11.14 10:12:22 1.16868 1.16869 0.0000        0 1510654342728       6
[1993] 2017.11.14 10:12:22 1.16868 1.16870 0.0000        0 1510654342834       4
[1994] 2017.11.14 10:12:22 1.16868 1.16869 0.0000        0 1510654342954       4
[1995] 2017.11.14 10:12:23 1.16867 1.16869 0.0000        0 1510654343339       2
[1996] 2017.11.14 10:12:27 1.16867 1.16868 0.0000        0 1510654347042       4
[1997] 2017.11.14 10:12:31 1.16867 1.16869 0.0000        0 1510654351428       4
[1998] 2017.11.14 10:12:31 1.16868 1.16869 0.0000        0 1510654351832       2
[1999] 2017.11.14 10:12:31 1.16869 1.16871 0.0000        0 1510654351942       6


What is this for? In INFO-mode this behaviour is handy, but in ALL you wait to get the raw data and only the GUI shows it.



If the price has not changed, it is null. As it is, the flags appear to be an unnecessary entity. Instead of showing null prices, increased MqlTick-structure by this flag.

Does tkc store only (without null prices) flags, store only (without flags) prices, or is it irrational to have both flags and prices there?


And why is a flag introduced?

  • TICK_FLAG_VOLUME – тик изменил объем

Whether the volume has changed or not is totally irrelevant. Or am I misunderstanding something?


ZS Raw ALL data is needed especially for custom characters, as it directly relates to the issue of data exchange channel through custom characters.

 
fxsaber:

Copitix in COPY_TICKS_ALL mode is amateurishly filling in zero Bid/Ask fields.


What it is done for? In the INFO-mode this behaviour is useful, but in ALL-mode we are waiting for the raw data, but they are shown only in GUI.



If the price has not changed, it is null. As it is, the flags appear to be an unnecessary entity. Instead of showing null prices, increased MqlTick-structure by this flag.

Does tkc store only (without null prices) flags, store only (without flags) prices, or is it irrational to have both flags and prices there?


And why is a flag introduced?

Whether the volume has changed or not is completely irrelevant. Or am I misunderstanding something?


SZY Raw ALL data is needed especially for custom characters, as it directly addresses the issue of data exchange channel through custom characters.


Do you write to servicedeck about the shortcomings you've identified?

It feels like everything goes to waste.


And why the flag?

  • TICK_FLAG_VOLUME - tick changed volume.

I think this is a very important indicator. How else can we know that the deal has been executed, and not just changed, moved bid ask?

 
Sergey Chalyshev:

Do you write to the service desk about any deficiencies you have identified?

The SD responds promptly to all requests. Further discussions are held there.

I think this is a very important indicator. How else would you know that the deal has been done and not only bid and ask have changed?

Only the flag is enough.

  • TICK_FLAG_LAST - the tick has changed the price of the last deal
By changing it to "trade passed". The fact that the last pricechanged - no one cares. There may be several deals in a row with the exact same price and volume. Therefore, there should only be one flag - the deal.
 

TICK_FLAG_VOLUME - tick changed volume

Somehow didn't think about what's written in the help before.

The volume of what did it change?

What does what is written above even mean?)

 
fxsaber:

The SR responds promptly to all requests. Further discussions are held there.

All that is needed is a flag.

By changing it to "trade passed". The fact that the price has changed is of no concern to anyone. There may be several deals in a row with the exact same price and volume. Therefore, there should only be one flag - a deal.

If it is responsive that's good.

As for the flags:

I also had this thought, in Expert Advisors to analyze the situation, to combine matching trades, it's kind of enough.

This situation - exchange time, server time, and computer time do not coincide. How do I know that MarketClosed, if there is a deal even at the last price, it means that the trade is in progress.

And if you combine all deals at one level, it is not clear what time the level was traded?

P.S. Extra flags do not affect the volume of flags transmitted.

 
Sergey Chalyshev:

If it responds, that's good.

About the flags:

I also had this idea, in EAs for situation analysis, to combine coinciding trades, it's kind of enough.

Such a situation - exchange time, server time, computer time do not coincide. How do I know that MarketClosed, if there is a deal even at the last price, it means that the trade is in progress.

And if you combine all the deals at one level, it will not be clear for how long the level was traded?

Why combine at one level? I would not merge, and leave the ribbon as it is now - what came from the exchange.

P.S. unnecessary flags do not affect the volume of flags transmitted.
Flags are forced measure, because MQ don't return raw data. They modify them inside CopyTicks.
 

The tkc files are broken down by month. Questions because of this

  1. If the terminal doesn't have the tick data uploaded yet, when you call CopyTicks, how will the terminal know which tkc files to pull?
  2. Is CopyTicksRange implemented based on CopyTicks or independently?
  3. Do I understand correctly, that getting the ticks for September, for example, will always be faster through the CopyTicksRange, than through CopyTicks, because CopyTicks doesn't know via the input parameters, for which month should it pull data?
  4. We need to get the history in the indicator as quickly as possible. It's possible to query via CopyTicksRange and get a bounce as -1, until everything is downloaded. And if you request by month: current month, then previous month, etc. It will not be slower, but the indicator will be ready to work with at least some history. Right?

Reason: