Tiki in real time

 

Good day to you all.

It became necessary to test the trading algorithm on real ticks of the broker "Otkritie".
So, the algorithm shows different results in the online mode and in the tester in the mode of real ticks.
Proceeding from this, the next step was the collection of ticks in real ticks and their comparison with history (history ticks), obtained by the CopyTicksRange() function.
The ticks were collected on the SBRF futures for 21.01.2020.

Interesting results have come out and some questions have arisen.

1. The number of real ticks and history ticks differs considerably, but the ticks at the beginning and at the end of the trading day are the same.
Perhaps, this is affected by a feature of the handler OnTick(), which can skip processing of ticks.

More than half of historical ticks, besides standard flags (TICK_FLAG_BID ... etc.) have an additional flag 9 bits enabled.
We don't see it in real ticks - there isn't a single tick with the 9-bit flag enabled.

3. We could not find any systematic difference between real and historical ticks, as well as the inclusion of bit 9 in historical ticks.
Historical ticks can completely correspond to real ticks, and the 9th bit in their flag can be switched on or off.
Real and historical ticks may be inconsistent even during periods of low trading activity, when the receipt of ticks in the terminal is not so intensive.

Ticks out

And the questions are accordingly:

To the developers - what does 9 bits in the tick flag mean?

And to the community - has anyone encountered such a collision?
How do you test the algorithms on real ticks? Only online?

Attached are files with collector and ticks analyser.
And real ticks on SBRF-3.20 for 21.01.2020.

Files:
ticks.zip  553 kb
 
Vladimir Mikhailov:

Good day to you all.

There is a need to test the trading algorithm on real ticks of broker "Otkritie".
So, the algorithm shows different results in online mode and in the tester in real ticks mode.
That's why the next step is collection of ticks in real time (real ticks) and their comparison with tick history (history ticks), obtained by the CopyTicksRange() function.
The ticks were collected on the SBRF futures for 21.01.2020.

Interesting results have come out and some questions have arisen.

1. The number of real ticks and history ticks differs considerably, but the ticks at the beginning and at the end of the trading day are the same.
Perhaps, this is affected by a feature of the handler OnTick(), which can skip processing of ticks.

2. more than half of historical ticks, besides standard flags (TICK_FLAG_BID ... etc.) have an additional flag 9 bits enabled.
We don't see it in real ticks - there isn't a single tick with the 9-bit flag enabled.

3. We could not find any systematic difference between real and historical ticks, as well as the inclusion of bit 9 in historical ticks.
Historical ticks can completely correspond to real ticks, and the 9th bit in their flag can be switched on or switched off.
Real and historical ticks may be inconsistent even during periods of low trading activity, when the receipt of ticks in the terminal is not so intensive.

And the questions are accordingly:

To developers - what does 9 bits in tick flag mean?

And to the community - has anyone encountered such a collision?
How do you test the algorithms on real ticks? Only online?

Attached are files with collector and ticks analyser.
And real ticks on SBRF-3.20 for 21.01.2020.

You made me laugh with your tick collector :)

Take "Tape of all trades" as a base.

https://www.mql5.com/ru/code/16210

Done

And forget about the tester for exchange instruments

Лента всех сделок
Лента всех сделок
  • www.mql5.com
Хитрый усреднитель Hello Smart Эксперт усредняет убыточные позиции по определенному алгоритму. ColorJSatl_Digit Сглаженный быстрый цифровой фильтр JSatl с цветовой индикацией направления движения, с отображением последнего значения в виде ценовой метки и с возможностью округлять уровни...
 
prostotrader:

You make me laugh with your tick collector :)

Take "All Transactions Feed" as a basis.

https://www.mql5.com/ru/code/16210

Completed

And forget about the tester for exchange instruments

The example above is just one way of aggregating the tape of trades, and again the reference is to the history.
Which I wouldn't want to do, as it slows down the algorithm. First of all, we are interested in those ticks which are processed by OnTick() event.

Forget the tester for MetaTrader in general or the tester in MT5?

 
Vladimir Mikhailov:

This example is just one of methods of aggregation of trades, and again it is a reference to history.
1. which you would not want to do, because it slows down the algorithm. First of all, we are interested in those ticks that are processed by OnTick() event.

2. Forget the tester for Exchange instruments in principle or the tester in MT5?

1. Nothing is slowing down and it won't.

You have been given a ready solution, which just needs to be adjusted to your needs.

The OnTick() event does not display all changes in the pick, i.e. it does not consider all ticks!

Here is a simple example for you to check

//+------------------------------------------------------------------+
//|                                                   Ticks_test.mq5 |
//|                                      Copyright 2019 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
//---
bool is_book;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
    is_book = MarketBookAdd(Symbol());
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
    if(is_book == true) MarketBookRelease(Symbol());
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
    Print(__FUNCTION__ + " Tick is done!");
   
  }
//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
  {
    if(Symbol() == symbol)
    {
      Print(__FUNCTION__ + " Tick is done!");
    }
   
  }
//+------------------------------------------------------------------+
2020.01.23 16:56:53.226	Ticks_test (GOLD-3.20,M1)	OnTick Tick is done!
2020.01.23 16:56:53.226	Ticks_test (GOLD-3.20,M1)	OnBookEvent Tick is done!
2020.01.23 16:56:53.712	Ticks_test (GOLD-3.20,M1)	OnTick Tick is done!
2020.01.23 16:56:53.712	Ticks_test (GOLD-3.20,M1)	OnBookEvent Tick is done!
2020.01.23 16:56:53.930	Ticks_test (GOLD-3.20,M1)	OnBookEvent Tick is done!
2020.01.23 16:56:53.996	Ticks_test (GOLD-3.20,M1)	OnTick Tick is done!
2020.01.23 16:56:53.996	Ticks_test (GOLD-3.20,M1)	OnBookEvent Tick is done!
2020.01.23 16:56:54.016	Ticks_test (GOLD-3.20,M1)	OnBookEvent Tick is done!
2020.01.23 16:56:54.280	Ticks_test (GOLD-3.20,M1)	OnBookEvent Tick is done!
2020.01.23 16:56:54.392	Ticks_test (GOLD-3.20,M1)	OnBookEvent Tick is done!

2. For Exchange instruments (already wrote that for the Stocks)

Added

If you decided to "crawl" from FOREX to the Exchange, then I recommend to find this topic in this

Help for Beginners" section and read it in details.

On the Exchange, Glass, not OnTick(), is the "head" of everything.
 
prostotrader:

1. Nothing is slowing down and nothing will.

You have been given a ready-made solution, which just needs to be tweaked to suit your needs.

The OnTick() event does not display all changes in the glass, i.e. not all ticks are taken into account!

Here is a simple example for you to check

2. For Exchange Traded Instruments (already wrote that for the Stocks)

Added

If you decided to "crawl" from FOREX to the Exchange, I recommend to find the topic in this

section "Beginners Guide" and read it in details.

On the Exchange, Glass, not OnTick(), is the "head" of everything.

1. You're right. The OnTick() event is not exactly related to the OnBookEvent() event.
The first event handles the arrival of new ticks - change of quotes, exchange deals.
The second event handles the change of the tick, which does not always result in a stock trade.
As the exchange deal doesn't necessarily pass through the ticker.
. I.e. we can say that the first event refers to the deals ticker, and the second event refers to the ticker.

2. What to use for analysis and decision making - the strip of deals or the slider or both, depends on the trading algorithm.

It seems I will have to use the OnTimer() event with a millisecond period for analyzing the strip.
I will continue to experiment.

 
Vladimir Mikhailov:

1. You are right. The OnTick() event is not exactly related to the OnBookEvent() event.
The first event handles the arrival of new ticks - change of quotes, stock trades.
The second event handles the change of the tick, which does not always result in a stock trade.
Neither does an exchange trade necessarily have to go through the cup.
I.e. we can say that the first event refers to the tape of trades and the second to the cup.

2. What to use for analysis and decision-making - the deal ticker or the market or both - depends on the trading algorithm.

It seems that I will have to use the OnTimer() event with a millisecond period to analyze the sliver of deals.
I will continue to experiment.

It is not a good idea to use a timer.

You have to decide what you want - to work in real time or by timer...

Your head is in a state of muddle.

Any change in the stack is a tick, which includes the "trades feed".

When OnBookEvent() is triggered, it means that:

1. A trade has occurred or

2. A new ASK has occurred or

3. A new Bid has appeared, or

4. Someone withdrew their pending order or

5. 5. ASK volume changed or

6 The Bid volume has changed

All this is reflected in OnBookEvent() ....

Good luck!

Added

In contrast to FOREX, where you trade with computer DC,

On the FOREX, you have real opponents (individuals and businesses)!

The exchange only "pairs" your orders(not for free, of course :) ) .

Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Приказы на проведение торговых операций оформляются ордерами. Каждый ордер имеет множество свойств для чтения, информацию по ним можно получать с помощью функций Идентификатор позиции, который ставится на ордере при его исполнении. Каждый исполненный ордер порождает сделку, которая открывает новую или изменяет уже существующую позицию...
 
<br / translate="no">

Unlike FOREX, where you trade with a DC computer,

On FOREX you have real counterparts (real individuals and businesses)!

The Exchange only "pairs" your orders(not for free, of course :) ) .

Have you heard about the ECN?

 
Aleksey Mavrin:

Ever heard of ECN?

)))))))))

Read about ECN


Обсуждение статьи "Выцарапываем профит до последнего пипса"
Обсуждение статьи "Выцарапываем профит до последнего пипса"
  • 2019.07.25
  • www.mql5.com
Опубликована статья Выцарапываем профит до последнего пипса: Автор: fxsaber...
 
Aleksey Mavrin:

Never heard of ECN?

Why did you come here?

Keep looking for the grail on the FOREX...

 
prostotrader:

Why did you come here?

Keep looking for the grail on FOREX...

What's your private territory here?

And it's not polite to tell people you don't know what to do. It shows a bit of a low level of your development.

 
Vladimir Mikhailov:

To the developers - what does bit 9 in the tick flag mean?

I don't know about bit 9, the question was about undocumented bit 7:

Forum on trading, automated trading systems and trading strategy testing

New version of MetaTrader 5 build 1930: Floating Chart windows and .Net libraries in MQL5

Slava, 2018.12.04 11:09

Alain Verleyen:

2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 1 tick: 2018.12.03 00: 52: 27.671 1.13338 / 1.13354 / 0.00000 0 flags:230
2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 2 tick: 2018.12.03 00: 52: 27.743 1.13335 / 1.13348 / 0.00000 0 flags:230
2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 3 tick: 2018.12.03 00: 52: 27.821 1.13327 / 1.13343 / 0.00000 0 flags:230
2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 4 tick: 2018.12.03 00: 52: 27.888 1.13326 / 1.13343 / 0.00000 0 flags:226
2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 5 tick: 2018.12.03 00: 52: 27.965 1.13327 / 1.13345 / 0.00000 0 flags:230
2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 6 tick: 2018.12.03 00: 52: 28.194 1.13328 / 1.13346 / 0.00000 0 flags:230
2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 7 tick: 2018.12.03 00: 52: 28.265 1.13328 / 1.13346 / 0.00000 0 flags: 96
2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 8 tick: 2018.12.03 00: 52: 28.327 1.13326 / 1.13344 / 0.00000 0 flags:230
2018.12.03 09: 58: 06.898 TicksInfo (EURUSD, M5) EURUSD: 9 tick: 2018.12.03 00: 52: 28.405 1.13326 / 1.13344 / 0.00000 0 flags: 96
2018.12.03 09: 58: 06.899 TicksInfo (EURUSD, M5) EURUSD: 10 tick: 2018.12.03 00: 52: 28.809 1.13326 / 1.13344 / 0.00000 0 flags: 96
2018.12.03 09: 58: 06.899 TicksInfo (EURUSD, M5) EURUSD: 11 tick: 2018.12.03 00: 52: 29.289 1.13326 / 1.13344 / 0.00000 0 flags: 96

Apparently the flag is bit by bit 7 (value 128,undocumented), is it possible to know the value?

This is a service flag that is set by the datafeed if the tick has not had the TICK_FLAG_BID flag set for any reason, while the tick should be applied to a bar.


Reason: