Download MetaTrader 5

Period calculation issue

To add comments, please log in or register
elfunambolo
106
elfunambolo  

Hello, I want to memorize in a variable the current time (when a condition happened) plus 5 Periods ( I'm testing EA in H1 timeframe).

This is the code:

if (RangecCandelaMax == High[1] - Low[1])  {
                  
       if ( Close[1] < iBands(NULL,0,50,2,0,PRICE_CLOSE,MODE_LOWER,1)){
   
         Print(" La candela [1] ha range più grande delle ultime 'n' e ha chiuso fuori la BB 50 INF ");
         
          timecondizione1Buy = TimeCurrent() + ( Period() * 5 );
          
          Print( "timecondizione1Buy = ", timecondizione1Buy);
   
      return(true);
   
       }

I expected to see timecondizione1 egual to TimeCurrent() + 5 hours but the variable is TimeCurrent() + 5 minutes (see attached picture).

How can I fix it?


Thanks

Giovanni

Files:
Carl Schreiber
7678
Carl Schreiber  
What about if you put in the editor the mouse above TimeCurrent() and hereafter above Period() and press F1 and read - especially what is their scale?
whroeder1
16572
whroeder1  
timecondizione1Buy = TimeCurrent() + ( Period() * 5 );
A datetime has units of seconds. Only add seconds. PeriodSeconds
To add comments, please log in or register