Download MetaTrader 5
To add comments, please log in or register
Join MQL5 Cloud Network affiliate program and make money!
michael sedgley
478
michael sedgley 2014.10.23 15:28 

I want to build in number of time period options to trade into my first code, is there an enumeration that could deal with a list of options. Thanks for any advice ! 

Carl Schreiber
5952
Carl Schreiber 2014.10.23 15:33  
Read the Book or study the docs
whroeder1
13623
whroeder1 2014.10.23 16:35  
artsedge: I want to build in number of time period options to trade into my first code, is there an enumeration that could deal with a list of options.
  1. Read the documentation.
  2. Every function that takes a time period, e.g. iCustom and iMA all contains links to Chart Timeframes - MQL4 Documentation
michael sedgley
478
michael sedgley 2014.10.24 09:45  
I see there is an enumeration for Timeframes for the range of different timesframes, but i was looking at trading at different times of the day say midnight to 9am or midnight to midday. 
whroeder1
13623
whroeder1 2014.10.24 12:39  
artsedge: I see there is an enumeration for Timeframes for the range of different timesframes, but i was looking at trading at different times of the day say midnight to 9am or midnight to midday. 
There are 86400 seconds in a day. Do you expect 86400 enumerations? Code a time filter
#define HR2400 (PERIOD_D1 * 60)  // 86400 = 24 * 3600
int      TimeOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                          return( when % HR2400 );            }
datetime DateOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
                                          return( when - TimeOfDay(when) );   }
//datetime Tomorrow( datetime when=0){      if(when == 0)  when = TimeCurrent();
//                                          return(DateOfDay(when) + HR2400);   }
//datetime Yesterday(datetime when=0){      if(when == 0)  when = TimeCurrent();
//   int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1);
//                                       return( iTime(NULL, PERIOD_D1, iD1) ); }

OnStart(){
   #define MIDNIGHT     0
   #define NOON     43200 // 12 * 3600
   int tod = TimeOfDay();
   if(tod >= MIDNIGHT && tod < NOON){ ...
michael sedgley
478
michael sedgley 2014.10.24 14:58  
Thank you very much for this - i hope you leave posted for other people learning like me.
michael sedgley
478
michael sedgley 2014.11.16 11:39  
could you complete the section that is missing after if( >= MIDNIGHT && tod < NOON) {
whroeder1
13623
whroeder1 2014.11.16 16:02  
artsedge: could you complete the section that is missing after if( >= MIDNIGHT && tod < NOON) {
You said "i was looking at trading at different times of the day say midnight to 9am or midnight to midday. " So call your trading code.
/
To add comments, please log in or register