Set timework EA

 

Hello, i want set my EA with these criteria: at 8:01 (8:01am) - START WORK

at 19:59 (7:59pm)- STOP WORK and close all open positions

please, can you write me the code? Ty

 
really nobody know s?
 

it's a bit vague.

What timeframe are you using?

is this Local time, Broker time, GMT, ...?

What do you mean by, "start work"?

Do you want 'pseudo code' that you can then code yourself into your EA, or do you want MQL4 code to mesh with your existing code?

How much are you willing to pay?

 
    int         DOW = TimeDayOfWeek(now),   /* forum.mql4.com/33851
    // reports DayOfWeek() always returns 5 in the tester. No refresh?*/
                DayMask = 1 << DOW;
    //                      #define DAYS_MAX    0x3F// 1<<6-1=63. (S-F)
    //extern int      Days.Mask               =  55;      // Not Wed
    if (Days.Mask & DayMask == 0){  StrApnd(EA.status," Day=",DOW); return; }
    //extern double   TradeHr.UTC.Start   =   7.3;    // London-1
    //extern double   TradeHr.UTC.End     =  12.9;    // NY open
    int secStart    = 3600*TradeHr.UTC.Start,
        secEnd      = 3600*TradeHr.UTC.End,
        hrBeg       = (now-secStart+86400)%86400,
        hrEnd       = (now-secEnd  +86400)%86400;
    if (hrBeg > hrEnd){ double Tminus=hrBeg/3600.-24;
                StrApnd(EA.status," HR", DoubleToStr(Tminus,2));    return; }