# time difference betwen two prices

64

Hello guy, how can I catch the time between two prices ? That's how I am trying:

```if(check == true && OrdersTotal()==0)
{

static double firstPrice;
static bool firstTest = false;
static bool secondTest = false;

if(firstTest == false)
{
//here I want to catch the first datetime
firstTest = true;
}

if(secondTest == false)
{
{
//here I want to catch the second datime
}

}

}//if(check == true && OrdersTotal()==0)```
7237

Sure!

1) Count ticks per minute and divide by 60 or (per 30 seconds or 10 seconds or ..)

2) Count ticks with the use of GetTickCount() (= millisecods).

64

thank you for the quick reply. I had the same idea to count the ticks per minute but how to do that ?
7237

sigh..

```int nTicks, TicksPerSec;
datetime NewBar;

void OnTicks(){
...
if ( NewBar != Time[0] ) {
TicksPerSec = nTicks/(_Period*60);
NewBar = Time[0];
nTicks = 1;
} else nTicks++;
...
}```
(untested) something like this?
15719

 gooly: sigh.. That's why I say:You have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem. Emphasis on "post your attempt."
64

@WHRoeder , your right. I updatet my first post!

@gooly thank you for helping me at the first problem, it works

64

7237

GetTickCount() - look it up in the reference
64

```if(check == true && OrdersTotal()==0)
{

if(firstTest == false)
{
//here I want to catch the first datetime

firstTest = true;
}

if(firstTest == true && mainTest == false)
{
m=GetTickCount();

{
showPrice = true;
mainTest=true;

}

if(showPrice==true)
{
}
}

}//if(check == true && OrdersTotal()==0)```
That is how I tried it but it doesent work ... I want that the Ea checks every tick the elapsed time betwen the firstPrice and the secondPrice which is the firstPrice-unterschied(difference) and the ea should return it to a variable.
I also tried it with m=TimeSeconds(TimeCurrent(); but it doesen't work
7237

sigh... :(

Just use and amend the example in the reference of GetTickCount()...

64

```int test()
{
int m = 0;
static int start = GetTickCount();
if(firstTest == false)
{

firstTest = true;
}

if(firstTest == true && mainTest == false)
{
m=GetTickCount()-start;
}
{

showPrice = true;
mainTest=true;

}

if(showPrice==true)
{

mainTest=false;
showPrice = false;

}

return(m);

}//int test()```
That's my code now. The first value which this function returns is right but then it will add up the first value with the second etc. Does someone know how to fix it ?
12