Download MetaTrader 5

Refering to Time 1 minute ago?

To add comments, please log in or register
john
213
john  

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
18024
Simon Gniadkowski  
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  
RaptorUK:

Time 1 minute ago is . . .



Fiver dude
Alain Verleyen
Moderator
32406
Alain Verleyen  
RaptorUK:

Time 1 minute ago is . . .

1 minute ago is :

TimeCurrent() - (PERIOD_M1 * 60);
Tonny Obare
1024
Tonny Obare  

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
18024
Simon Gniadkowski  
angevoyageur:

1 minute ago is :


oops . . . yep, of course it is . . . answer in haste repent at leisure
Simon Gniadkowski
Moderator
18024
Simon Gniadkowski  
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  
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  
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