Features of the mql5 language, subtleties and tricks - page 29

 
Andrey Dik:

In testing, minute data is considered more reliable.

Are minute bars more reliable? Isn't tick data the last resort? Why do we even need real tick data if it's not taken into account?

In my naivety, I used to do this: I was testing on minute bars, then I was testing on ticks, then I was testing on real ticks as a final precision check. Now I understand that the third check does not make much sense.


The legs grow from here

https://www.mql5.com/ru/forum/188047

Не совпадают цены тестера и CopyTicks, или неверная синхронизация?
Не совпадают цены тестера и CopyTicks, или неверная синхронизация?
  • www.mql5.com
Пытаюсь сделать мультивалютный советник,но с фьючами. Запускаем в тестере простой советник на ближнем фьюче,т.к. он более живой...
 
Vladimir Karputov:


No need to take the sentence out of context. The phrase sounds like this:

As you can see, if you don't try to manipulate, it turns out that you misinterpreted the reference.

I didn't manipulate anything. The reference clearly states that the minute bars are of paramount importance. For lack of tick data - ticks are generated according to minute bars.

In my opinion, the minute TF should be formed from real ticks in the "Real ticks" mode, otherwise there is no sense in this mode.

 
Andrey Dik:

In my opinion, the minute TF should be formed from real ticks in the mode "Real ticks", otherwise there is no sense in this mode.


Focusing on the minute history and leads to a situation where the real ticks from 02.04.17 to 08.04.17

2017.04.08 18:06:17.780 сколько тиков (GOLD-9.17,H1)    Колво тиков за 2017.04.02 00:00:00 = 116844

And the tester uses ticks only for 88 existing minute bars. All other ticks exist only somewhere in ...

2017.04.08 18:05:17.263 Core 1  GOLD-9.17,M1: 5918 ticks, 88 bars generated. Environment synchronized in 0:00:00.070. Test passed in 0:00:03.125 (including ticks preprocessing 0:00:00.070).
2017.04.08 18:05:17.263 Core 1  GOLD-9.17,M1: total time from login to stop testing 0:00:03.195 (including 0:00:02.944 for history data synchronization)
2017.04.08 18:05:17.263 Core 1  166135 total ticks for all symbols
2017.04.08 18:05:17.263 Core 1  GOLD-9.17: generate 5918 ticks in 0:00:00.020, passed to tester 5918 ticks
 
The tester log
GOLD-6.17,H1: testing of Experts\fxsaber\Test2.ex5 from 2017.04.03 00:00 to 2017.04.08 00:00 started
GOLD-6.17 : real ticks begin from 2017.04.03 00:00:00
final balance 100000.00 EUR
GOLD-6.17,H1: 145777 ticks, 70 bars generated. Environment synchronized in 0:00:01.388. Test passed in 0:00:00.062 (including ticks preprocessing 0:00:00.031).

And here is the number of real ticks


This is Metaquotes-Demo.

It turns out that the real ticks are 147700 for the week, while the tester in its most accurate mode gives 145777 of unknown ticks.

 
fxsaber:
Tester Log

And here is the number of real ticks


This is Metaquotes-Demo.

It turns out that the real ticks are 147700 for the week, and the tester in its most accurate mode gives 145777 of unknown ticks.


The tester uses less ticks than it was in reality, because it is oriented on them.

better look at long futures, the picture is more clear there

 
kaus_bonus:


There are several M1 bars missing and since the landmark is on them, the tester uses less ticks than it really was.

M1-bars are formed when there is a flipper price. If there is not, there is no bar. And the fact that there were bid/ask ticks at that time is ignored!

This means that the problem is not only in the tester, but also in the algorithm of bar formation.

It's better to look at long futures, the picture there is more clear.

Exactly at long futures this situation, as I wrote above, most often happens.

You are right, I'll just show the proof of this situation more clearly

GOLD-9.17,H1: testing of Experts\fxsaber\Test2.ex5 from 2017.04.03 00:00 to 2017.04.08 00:00 started
GOLD-9.17 : real ticks begin from 2017.04.03 00:00:00
final balance 100000.00 EUR
GOLD-9.17,H1: 5918 ticks, 39 bars generated. Environment synchronized in 0:00:00.032. Test passed in 0:00:00.046.

The real ticks are 116844, the tester ticks in the most precise mode are 5918. A modest 20 times less.


SZY A refutation of the hypothesis that this situation is caused by the tester skipping of identical ticks

#include <TypeToBytes.mqh>

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

void OnStart()
{
  MqlTick Ticks[];
  
  const int Amount = CopyTicksRange(_Symbol, Ticks, COPY_TICKS_ALL, D'2017.04.03' * 1000, D'2017.04.08' * 1000);
  
  int Count = 1;
  
  for (int i = 1; i < Amount; i++)
    if (_R(Ticks[i]) != Ticks[i - 1])
      Count++;
      
  Print(TOSTRING(Amount) + TOSTRING(Count));
}
Result
Test2 (GOLD-9.17,H1)    Amount = 116844 Count = 116840

Only 4 identical ticks could be missed.

 
Translation of MqlTick to string

Forum on trading, automated trading systems and testing trading strategies

Libraries: Price_Compare

fxsaber, 2016.10.19 17:18

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));
}

void OnStart()
{
  MqlTick Tick;
  
  if (SymbolInfoTick(_Symbol, Tick))
    Print(TickToString(Tick));
}
Result
time = 2017.04.07 23:58:18.000 bid = 110620.0 ask = 110640.0 last = 110630.0 volume = 1 TICK_FLAG_BID TICK_FLAG_ASK TICK_FLAG_LAST TICK_FLAG_VOLUME
 
fxsaber:
Translating MqlTick to string
Result

Unreadable:

time = 2017.04.07 23:58:18.000 bid = 110620.0 ask = 110640.0 last = 110630.0 volume = 1 TICK_FLAG_BID TICK_FLAG_ASK TICK_FLAG_LAST TICK_FLAG_VOLUME
 
Dennis Kirichenko:

It's unreadable:

I don't get it. I use it myself to print any simple structures, types and arrays.

Forum on trading, automated trading systems and trading strategy testing

MetaEditor build 1463

fxsaber, 2016.11.10 10:42

class PRINTCLASS
{
public:  
  template <typename T>
  static void MyPrint( const T &Value )
  {
    T Array[1];
    
    Array[0] = Value;
    
    ::ArrayPrint(Array, _Digits, NULL, 0, WHOLE_ARRAY, ARRAYPRINT_HEADER|ARRAYPRINT_LIMIT|ARRAYPRINT_ALIGN);
  }
  
  template <typename T>
  static void MyPrint( const T Value )
  {
    ::Print(Value);
  }

  template <typename T>
  static void MyPrint( const T &Value[] )
  {
    ::ArrayPrint(Value);
  }
};

#define Print(A) PRINTCLASS::MyPrint(A)

void OnStart()
{
  MqlTick Tick;
  
  if (SymbolInfoTick(_Symbol, Tick))
    Print(Tick);
}

The result
             [time]   [bid]   [ask]  [last] [volume]    [time_msc] [flags]
2017.04.07 23:58:18  110620  110640  110630        1 1491609498000      30

It all depends on the goals.
 
Reason: