Tiki in real time - page 20

 
Roman:

You've made a mess of everything.

As I wrote earlier, trades and level2 are different data subscriptions, so they are different event handlers.
That's why trades need to be called from OnTick, and volume gangs from OnBook.
You're trying to call trades from OnBook events and gangs from OnTick. All the while thinking that OnBook will be faster for trades.
It won't be faster, I think it's a delusion to compare two event handlers intended for each of the different data threads.
I understand that this is all experimentation, but without understanding the logic of sockets you will endlessly confuse these OnTick and OnBook handlers.

I've already written, in case you haven't seen, "there's no alternative to OnBookEvent() for me".

And all the codes, results, explanations - to make it clear why.

Judging by your post - you don't understand... :)

Maybe you're reading the message?

I can get all the data quickly and easily via OnBookEvent() without using OnTick().

but I can get not all data with OnTick(). So why should I use OnTick()?

 
prostotrader:

I've already written, in case you haven't seen, "for me there is no alternative to OnBookEvent()".

And all the codes, results, explanations - to make it clear why.

Judging by your post - it's not clear to you... :)

Maybe you're reading through the topic?

Yes, I understand that in your case there is no alternative, and rightly so.
And I understand what you're talking about. I just wanted to emphasize this point, that trades and Level2 are different data streams.
We have to remember about it, and those who don't know about it should know.
That's why if you need trades, you should call functions necessary for it from OnTick,
If you need bid asc with volume, or depth of a cup, then appropriate functions must be called from OnBook.
It's not correct to take events from OnBook and get trades, and try to get volumes or depth from OnTick events.
And so I understand that you are just explaining to others, and experimenting along the way.

 
Roman:



And so I understood that you're just explaining to others, and experimenting along the way.

You got that right.

I just did similar experiments 7 years ago, I chose OnbookEvent().

And now I decided to check if something has changed... It hasn't.

 
prostotrader:

The fact is that the Derivatives Market (FORTS), even on "highly liquid" instruments, is very weak,

It means that you can buy a verylimited number of contracts at the right price, so you need not only the price,

The volume of contracts at this price is very important.


And SymbolInfo doesn't give the volume of this price.

Therefore, we need to useMarketBookGet() that provides both price and volume for the whole book.

What does it have to do with the subject? That's the only reason why I'm stuck. I don't need OnBook to get ticks, because OnTick is definitely not slower.

And why say 20 times each about OnBook's indispensability? Is anyone doubting it?


prostotrader:

And I don't agree that when OnTck() is triggered we can get ticks from history.

By remembering the last tick time, when OnTck() is triggered, we can get the ticks

a new tick(s) came in real time - OnTck() is triggered, we read it immediately, i.e. it's not history.

Any tick coming into the terminal is already history.

But I wasn't talking about that, but about building the tape without gaps(SymbolInfoTick won't help with that).

 
Aleksey Mavrin:

Wanted to put the code to test first

But I can't open the demo opener account for something. Time is probably out of order, or are there more complications?

Tiki in real time

prostotrader, 2020.01.31 13:18

Account : 1007932

Investor : FfiR87ty (read only password)
 
Andrey Khatimlianskii:

What does this have to do with the topic? That's the only reason I'm getting into it, you don't need OnBook to get ticks, as OnTick is definitely not slower.

And why say 20 times each about OnBook's indispensability? Is there anyone doubting it?

Any tick coming into the terminal is history.

But that's not what I was talking about, I was talking about building a tape without skips (SymbolInfoTick won't help with that).

You seem to misunderstand each other :)))
He tells you about the best bid suits with volume, and you tell him about trades and deals :))
All right, I think we got it all straightened out.

Well, it depends on how you look at the coming tick - this is history.
If for the server of the exchange, then yes it is history, for the terminal not so.
Because the terminal for OnTick stores last 4096 records in cache, for hot access to them, and then dumps them to the history to the disk.
Then it turns out it's not quite history yet ))), that is, emergency shutdown will not save the cache to disk.
And when terminal rest arts, the lost data in cache will be downloaded from server. But this only applies to OnTick data.
OnBook will probably not load the data.

 

I thought there was at least one OnBook for every OnTick. but then I didn't understand this


 

Put this code on Opening Demo to calculate average and max delay between OnTick and the next OnBook.

The code is on hand, may be crooked, I'll look at the results.

//+------------------------------------------------------------------+
//|                                                   TestOnBook.mq5 |
//|                                           Copyright 2019, Allex@ |
//|                                                 alex-all@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, Allex@"
#property link      "alex-all@mail.ru"
#property version   "1.00"
//---
bool is_book;
enum ENUM_BOOK_OR_TICK
{
        USE_BOOK,       // Use OnBookEvent
        USE_TICK        // Use OnTick
};

input ENUM_BOOK_OR_TICK Mode = USE_BOOK;
input int   SecForPrint =  300;
//---
ulong TimeArrayBook[65536];
ulong TimeArrayTick[65536];
ushort curBook,curTick;
ulong  DelaySum=0,DelayCount=0;
int delay,delayMax=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   curBook=0;
   curTick=0; 
   ArrayInitialize(TimeArrayBook,INT_MAX);
   ArrayInitialize(TimeArrayTick,INT_MAX);
  if(Mode == USE_BOOK) is_book = MarketBookAdd(Symbol());
  if (EventSetTimer(SecForPrint)) 
  return(INIT_SUCCEEDED);
  else return (INIT_FAILED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
  if(Mode == USE_BOOK)
  {
    if(is_book == true) MarketBookRelease(Symbol());
  }  
}
//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{ 
  TimeArrayBook[curBook++]=GetMicrosecondCount();
 }
void OnTick()
{
  TimeArrayTick[curTick++]=GetMicrosecondCount();
}
//+------------------------------------------------------------------+
void OnTimer()
  {
   string out=NULL;
   int total=MathMax(curBook,curTick);
   int i=0,k=0;
   while(i<total)
     {
      while(i<total && TimeArrayBook[i]<TimeArrayTick[k] )
        {
          Print("Book ",TimeArrayBook[i++]);
        }    
      if(k<curTick-1)
        {
        if(i<total)
          {
           delay=TimeArrayBook[i]-TimeArrayTick[k];
           if (delay>delayMax) 
            delayMax=delay;
           if (delay>0)
              {
                 DelaySum+=delay;
                 DelayCount++;
              }
          }
         Print("Tick ",TimeArrayTick[k++]);
        }       
        i++;
     }
     if (curTick>0)
     {
     Print("Tick ",TimeArrayTick[curTick-1], " last");
     string out="Count Event Book after Tick "+DelayCount+". Delay Average "+DoubleToString(DelaySum/DelayCount,2)+". Max "+delayMax;
     Print (out);
     Comment(out);
     }
     curBook=0;
     curTick=0;
  }
//---  
 
Andrey Khatimlianskii:

Any tick that comes into the terminal is already a story.

But that's not what I was talking about, I was talking about building a tape without skips (SymbolInfoTick won't help with that).

Ok. Your point about history is quite clear.

But I still stand by my opinion, that the method of getting the ticks will depend on

their reading (from history or in real time).

And I didn't disagree with you about SymbolInfoTick and the tape without skips.

 

That's the picture for the day. Of course we did not check whether OnBook matched Tick, but just took the next one, hoping that if OnTick was ahead of OnBook, then the corresponding one would be either the same or slightly later.

Maximum of course without additional checks is no indicator, or overshoot or really OnBook somewhere slow.


But this is someone who can explain? Why are so many OnTickers unrun, and not a single OnBook between them?


Reason: