Auto close after duration script - page 2

 
Oyster55:

Thanks for all your efforts, folks. I can see you'all are pretty hardcore and careful about details. So, I appreciate that. I like the idea of just counting minute-bars (my EA only uses minutes) - seems simple for me, but I am now concerned if too many are missed. Does anyone have any idea how many minute-ticks are missed in say, first opening hours of the week? (slowest activity in my experience)

The number of "missing" bars varies by broker. An STP or ECN broker will have somewhere between none and a small number per week. A B-book broker may have quite a few, generally overnight (in GMT terms).

You can count the number of bars by taking an order's OrderOpenTime() and looking up the corresponding bar index using iBarShift().

 
  1. jjc:

    The number of "missing" bars varies by broker. An STP or ECN broker will have somewhere between none and a small number per week. A B-book broker may have quite a few, generally overnight (in GMT terms).

    You can count the number of bars by taking an order's OrderOpenTime() and looking up the corresponding bar index using iBarShift().

    Depending on how long you want the order to stay, use larger bars like H1 in the iBarShift(). Alternatively count the missing bars like "Free-of-Holes" Charts - MQL4 Articles

  2.    int Weekends = (lElapsedTime / 604800);
       int lDoWStart = TimeDayOfWeek(dtStartTime);
       int lDoWEnd = TimeDayOfWeek(dtEndTime);
    Besides weekends there are holidays where some brokers will be closed. Christmas is mostly all closed while US brokers close for July 4.
Reason: