How to calculate the time of the last two TICK (ms) and the price?

How to calculate the time of the last two TICK (ms) and the price?

record the microsecond counter content, first line, inside ontick().
and compare it to it’s previous value. (a static variable)

In metatrader, a tick is defined as price change. Therefore, you don’t calculate ticks. Ticks are received by the metatrader terminal so you just need to record and compare them.

Backtesting ticks are calculated and I don’t know if it is possible to record them.

Sorry, because your English is not good, familiar with English BBS not, just see the reply today, thank you!
I have no idea about programming, ponder programming is as follows:
Void OnTick ()
{

Uint start = GetTickCount ();
OnTick ();
Print (GetTickCount () - start);

}

After printing errors: Stack overflow in. How can I solve this error? Thank you very much!

Thank you so much for your reply, I am your English translation software in English translation, some translation is not so smooth. I want to see how to calculate the Posting means what is the difference between the two Tick.

My English is not good, translation software translation errors, please forgive me!!! ! ! ! ! ! !

Void OnTick ()
{


Int num = 0, I = 0;
Uint start = GetTickCount ();
For (I = num; I > 0; I --.)
OnTick ();

Print (GetTickCount () - start);

/ / print the result is 0

}
  1. Don’t call OnTick() function, from Ontick(). [ actually don’t make any function call itself , because you’re not so good at programming, as you mentioned.]
    do something like this :
OnTick()
{
        static ulong Previous_Tick_Time = 0;
        ulong This_Tick_Time = GetMicrosecondCount();
        Print("MicroSecond deiiference between recent two ticks : ", This_Tick_Time - Previous_Tick_Time);
        Previous_Tick_Time = This_Tick_Time ;
        // rest of your code...
        // remember, 1,000,000 microseconds make one second.
}

why you need time difference between two ticks ? if you want to somehow measure the volatility of the market at the moment, there are better procedures.

Thank you, thank you very much!
I think, high-frequency smallest unit should be Tick, Tick if can find the time and space, perhaps can have the harvest!

void OnTick()
  {
       static ulong Previous_Tick_Time = 0;
        ulong This_Tick_Time = GetMicrosecondCount();
        //Print("MicroSecond deiiference between recent two ticks : ", This_Tick_Time - Previous_Tick_Time);
        Previous_Tick_Time = This_Tick_Time ;
        // rest of your code...
        // remember, 1,000,000 microseconds make one second.
        Print("MicroSecond deiiference between recent two ticks : ", This_Tick_Time - Previous_Tick_Time); 
   
  }


Why do I put the “Print (” MicroSecond deiiference between recent two ticks:", This_Tick_Time - Previous_Tick_Time); "On the printing result is below zero? If I want to call “This_Tick_Time - Previous_Tick_Time” this value to operation, how should do?

you can omit using Print() , it just shows the time difference for you to see it.
you can store the value of that time difference in a variable and use it in rest of your code.
so instead of printing the value, save it :slight_smile:

ulong L2TTD = This_Tick_Time - Previous_Tick_Time; // L2TTD is the variable that stores Last 2 Ticks Time Difference

I don’t understand your purpose yet :slight_smile:

that time difference isn’t gonna show you valuable information as it can be affected by disconnections and weekends and other closed-market times.
you can work with more number of these time differences and save them in an array, and check the array average with every tick.
this way you can detect slow increases/decrease in tick retrieval speed, when they happen. ( and somehow gauge activity of the market :s )
if that’s what you mean by “if can find the time and space, perhaps can have the harvest” then you better understand volume indicators.
I don’t know any other good use for tick time differences.

Wouldn’t copying last two (or more) ticks into an array and comparing time_msc be better?

You can even put up an average or something like that.

if asking me, I’m not sure what he wants.
I just suggested a more-understandable-for-him solution to use the time differences he is concerned with.

Thank you very much! Thank you very much! Problem has been solved!!!
You said is right, you reminded me, I now just observed that will produce the error between the Tick, and I began to think different. I was just want from Tick1 jump Tick0 between the end of time, now just know if on the Tick1 and residence time, this will produce the error. If we can remove the stay this time, as long as the play Tick0 Tick1 jump between the time will be more accurate!
An array of you say, I want to have a research study, he found himself so much to learn!
Still want to thank, finally found what I want! Thank you for your patience, you are a good man, thank you!

@nthurbyx Your idea is very good, I just want to get the last two Tick, try many methods are not ideal, because of my poor programming, has only just begun to learn programming. “Array” is a good thing, it’s a pity that I don’t know how to use. Thank you for your advice, thank you!!!