Tiki in real time - page 7

 
prostotrader:

You have to post your code to prove or disprove something!

You took it upon yourself to prove that there are records between adjacent OnTick events, which then get into the CopyTicks-history and can be caught in real time via OnBookEvent.

Unfortunately, the above logs don't show this.

 
fxsaber:

You are proving that there are records between adjacent OnTick events, which then get into the CopyTicks history and can be caught in real time via OnBookEvent.

Unfortunately, the above logs don't show this.

I proved it by posting the working code and explained why it works faster and in real time,

I've based it on MQL5 function's help and personal experience.

Want to check it yourself? Or prove the opposite with a working code.

 
prostotrader:

I proved this by posting working code and explaining why it works faster and in real time.

Unfortunately, when the main proof link in the form of missing OnTick CopyTicks-history entries is missing, it cannot be accepted.

 
fxsaber:

Unfortunately, when the main link of the proof is missing in the form of missing OnTick CopyTicks-history records, it cannot be accepted.

So what's the problem?

Check it out for yourself.

 
prostotrader:

So what is it?

Check it out for yourself.

Only pointed out that your proof cannot be accepted solely on logical grounds, and not as contradicting any other point of view.

 
fxsaber:

Just pointed out that your proof cannot be accepted solely for logical reasons, and not as contradicting any other point of view.

OK, I see, but I still suggest reading the help on OnBookEvent()

I'm not going to prove anything, I just wrote a working code in the subject of the topic, and explained (at request of forum users)

Why this method is better than OnTick(), if someone doesn't believe me, let him check it himself!

Or post a working code that disproves my explanation.

Added by

There are thousands of FOREX people here on the forum who have never worked with OnBookEvent()

And with a tumblr.

What am I supposed to do something for everyone who will post in this thread?

 
prostotrader:

Time of first OnTick()2020.01.30 19:31:11.112

time of second OnTick()2020.01.30 19:31:11.802

That is, 690 ms have passed, meanwhile, between the OnTick() of these 690 ms

OnBookEvent() was triggered 15 times

Do you think that these clicks have nothing to do with ticks?

Unless you call a change in the stack that doesn't affect the edge band (bid/ask) or flipper, then yes, these triggers have nothing to do with ticks.


prostotrader:

There is another essential point that many people forget about.

It's the speed at which the EA makes a decision by analyzing the input data.

Using OnBookEvent() instead of OnTick(), my EA will be faster than yours.

You are mistaken, and I'm telling you this for the thousandth time.

You can run this EA on one terminal on two charts: one in mode "Use OnBookEvent", the second - in mode "Use OnTick" (this is the input parameter). The code inside the event handlers is identical (you can put it in a separate function and call it from there, but that's not the point):

//---
enum ENUM_BOOK_OR_TICK
{
        USE_BOOK,       // Use OnBookEvent
        USE_TICK        // Use OnTick
};

input ENUM_BOOK_OR_TICK Mode = USE_BOOK;

//---
bool is_book;
long last_tick_time = 0;
MqlTick cur_ticks[], last_tick;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
        if ( Mode == USE_BOOK )
        {
                is_book = MarketBookAdd(Symbol());
                if ( !is_book ) Alert( "MarketBookAdd failed with error #", GetLastError(), "!" );
        }

        last_tick_time = 0;

        return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
        if(is_book == true) MarketBookRelease(Symbol());
}

//+------------------------------------------------------------------+
//| BookEvent function                                               |
//+------------------------------------------------------------------+
void OnBookEvent(const string &symbol)
{
        if ( Mode != USE_BOOK || symbol != _Symbol ) return;

        if ( last_tick_time <= 0 )
        {
                if ( CopyTicks( _Symbol, cur_ticks, COPY_TICKS_ALL, 0, 1 ) > 0 )
                {
                        last_tick_time = cur_ticks[0].time_msc;
                        last_tick = cur_ticks[0];
                }
        }
        if ( last_tick_time > 0 )
        {
                int new_ticks = CopyTicks( _Symbol, cur_ticks, COPY_TICKS_ALL, last_tick_time, 0 );
                for ( int i = 0; i < new_ticks; i ++ )
                {
                        PrintTick( "OnBook", cur_ticks[i] );
                }
                if ( new_ticks > 0 )
                {
                        last_tick_time = cur_ticks[new_ticks-1].time_msc;
                        last_tick = cur_ticks[new_ticks-1];
                }
        }
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
{
        if ( Mode != USE_TICK ) return;

        if ( last_tick_time <= 0 )
        {
                if ( CopyTicks( _Symbol, cur_ticks, COPY_TICKS_ALL, 0, 1 ) > 0 )
                {
                        last_tick_time = cur_ticks[0].time_msc;
                        last_tick = cur_ticks[0];
                }
        }
        if ( last_tick_time > 0 )
        {
                int new_ticks = CopyTicks( _Symbol, cur_ticks, COPY_TICKS_ALL, last_tick_time, 0 );
                for ( int i = 0; i < new_ticks; i ++ )
                {
                        PrintTick( "OnTick", cur_ticks[i] );
                }
                if ( new_ticks > 0 )
                {
                        last_tick_time = cur_ticks[new_ticks-1].time_msc;
                        last_tick = cur_ticks[new_ticks-1];
                }
        }
}

void PrintTick( string func_name, MqlTick &tick )
{
        if ( tick.time_msc == last_tick.time_msc &&
                        tick.bid == last_tick.bid &&
                        tick.ask == last_tick.ask &&
                        tick.last == last_tick.last ) return;
        Print( GetTickCount64(), ": tick received from ", func_name, ": ",
                        tick.time, "   ", tick.time_msc, "  ",
                        DoubleToString( tick.bid, _Digits ), " / ",
                        DoubleToString( tick.ask, _Digits ), " / ",
                        DoubleToString( tick.last, _Digits ) );
};

And then look in the EA's log, and analyze the time of tick receipt:


If you find something interesting (for example, the time of getting a tick(GetTickCount64) from OnTick is longer than the same time (for the same tick) from OnBook), post it here.

 
Andrey Khatimlianskii:

If you don't call a change in the cup that doesn't affect the edge band (bid/ask) or flipper, then yes, those triggers have nothing to do with ticks.


You are mistaken and I am telling you this for the thousandth time.

Run this EA on one terminal on two charts: one in "Use OnBookEvent" mode, the other in "Use OnTick" mode (this is the input parameter). The code inside the event handlers is identical (you can put it in a separate function and call it from there, but that's not the point):

And then look in the EA's log, and analyze the time of tick receipt:


If you find something interesting (for example, the time of getting a tick (GetTickCount64) from OnTick is longer than the analogous time (for the same tick) from OnBook), post it here.

It's just like I said!

In the first line of the log (joint work) is a direct confirmation of my explanations

OnTick() is triggered late, and therefore receives outdated data


Files:
20200131.log  220 kb
 
prostotrader:

It's just like I said!

The first line of the log (collaboration) directly confirms my explanation

OnTick() is triggered late, so it gets outdated data

Show some information before this piece of log.

Was it right after launch (the very first entries)? In what order did you run the EAs?

ps: see the attached log, will have a look now

 
Andrey Khatimlianskii:

Show some information before this piece of log.

Was it right after the launch (the very first entries)? In what order did you run the EAs?

Onbook first, then ontic, log attached above