# Trading at certain times.

391

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 !

Moderator
7648

Read the Book or study the docs
17946

 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. Read the documentation.Every function that takes a time period, e.g. iCustom and iMA all contains links to Chart Timeframes - MQL4 Documentation
391

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.
17946

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){ ...
391

Thank you very much for this - i hope you leave posted for other people learning like me.
391

could you complete the section that is missing after if( >= MIDNIGHT && tod < NOON) {
17946

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