can I write time() function

To add comments, please log in or register
Bill Morris
287
Bill Morris  

I'm new to MT4.

Is there any reason I should not write a "time()" function (lower case "t")? I'm tired of writing "NULL", all the time.

datetime time(int iBar, int pTimeFrame = 0)
   {
      if (pTimeFrame == 0)
         return Time[iBar];
      else
         return iTime(NULL, pTimeFrame, iBar);
   }
Simon Gniadkowski
17677
Simon Gniadkowski  
FoxGuy:

I'm new to MT4.

Is there any reason I should not write a "time()" function (lower case "t")?

As far as I can see, two reasons that may well not matter to you . . .

  1. code readability for other people
  2. if you code gets to be time critical it will be a little slower

. . you did say "any" reason ;-)
zzuegg
1504
zzuegg  

I can only suggest to use a better readable function name like:

getTimeOfBar(int iBar,int pTimeFrame=0, string symbol=NULL){

 //

}
You keep the possiblity of using different timeframes/symbols, but you don't have to if not needed
An no, generally you could name your function time. 
To add comments, please log in or register