Download MetaTrader 5

Refering to Time 1 minute ago?

To add comments, please log in or register
Documentation is available in CHM and PDF. Download it in any convenient form!
john
213
john 2013.11.23 17:44 

Hi,

I'm trying to refer to a piece of data just once every minute.

Something like if time>time[1] ...

In mql4 how would I write that condition? I've tried multiple ways and can't get it to work. I've looked through the documentation all morning (and searched the internet) and cannot find this basic example or this piece of info that tells me how to refer to past time periods.

Thanks

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.11.23 17:47  
moneycode:

Hi,

I'm trying to refer to a piece of data just once every minute.

Something like if time>time[1] ...

In mql4 how would I write that condition? I've tried multiple ways and can't get it to work. I've looked through the documentation all morning (and searched the internet) and cannot find this basic example or this piece of info that tells me how to refer to past time periods.

Time 1 minute ago is . . .

TimeCurrent() + (PERIOD_M1 * 60);
john
213
john 2013.11.23 17:48  
RaptorUK:

Time 1 minute ago is . . .



Fiver dude
Alain Verleyen
Moderator
30755
Alain Verleyen 2013.11.23 18:10  
RaptorUK:

Time 1 minute ago is . . .

1 minute ago is :

TimeCurrent() - (PERIOD_M1 * 60);
Tonny Obare
1024
Tonny Obare 2013.11.23 18:19  

Or quick style.

int NextRun;

 
int start()
{
 if(TimeCurrent>=NextRun)
   {
     // do something here then
      
     NextRun=TimeCurrent+60;
   }
return(0);
}

Whatever you place in place of the comment "do something here" will run every minute.

Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.11.23 18:46  
angevoyageur:

1 minute ago is :


oops . . . yep, of course it is . . . answer in haste repent at leisure
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.11.23 18:47  
tonny:

Or quick style.

Whatever you place in place of the comment "do something here" will run every minute.

No, it won't . . . if there are no ticks for 5 minutes then it won't run for 5 minutes.
john
213
john 2013.11.23 21:59  
tonny:

Or quick style.

Whatever you place in place of the comment "do something here" will run every minute.


That one did work too, ( I just had to add () after the TimeCurrent, which I guess was okay to do)

The time all the way over to the right shows 60 second intervals which is what I wanted.

If there is a pause for no ticks as Raptor noted, that wouldn't affect my purpose.

My purpose was to verify my indicator parameters at specific trade bars in back-test mode, and I didn't want to fill up the print log with multiple prints from the same bar.

Also in determining a Mean and other calculations from the data, I didn't want multiple entries from the same bar to throw off my results.


print out

Tonny Obare
1024
Tonny Obare 2013.11.24 09:56  
moneycode:

That one did work too, ( I just had to add () after the TimeCurrent, which I guess was okay to do)

The time all the way over to the right shows 60 second intervals which is what I wanted.

If there is a pause for no ticks as Raptor noted, that wouldn't affect my purpose.

My purpose was to verify my indicator parameters at specific trade bars in back-test mode, and I didn't want to fill up the print log with multiple prints from the same bar.

Also in determining a Mean and other calculations from the data, I didn't want multiple entries from the same bar to throw off my results.






To add comments, please log in or register