Not logged in
Viewing 3 posts - 1 through 3 (of 3 total)

Forums>AlgoWizard / EA Wizard>Application Support>Delay order send by x minutes

  • #234616 |
    Customer
    2 Posts

    Hi All

    I have developed an EA in SQ EA Wizard to trade daily (on the daily charts), it opens a trade at the start of the new trading day, in order to avoid any gapping in the price level I need to delay the opening of the order by say 5 minutes into the new day.

    I have tried all the methods I know and have found reference to such code in the sample portfolio:-

    extern int OpenBarDelay = 0; // open bar delay in minutes
    // it can be used for Daily strategies to trigger trading a few minutes later –
    // because brokers sometimes have technical delay after midnight and we have to postpone order

    and the corresponding reference to OpenBarDelay

    //+——————————————————————+

    void drawStats() {
    // changed recognition of bar open to support also range/renko charts
    static datetime tmp;
    static double open;

    if (tmp != Time[0]) { // } || open != Open[0]) { – this doesn’t work with renko charts

    bool processBarOpen = true;

    if(OpenBarDelay > 0) {
    // set bar to open only after X minutes from real open
    processBarOpen = false;

    int diffInSeconds = TimeCurrent() – Time[0];
    if(diffInSeconds >= OpenBarDelay * 60) {
    processBarOpen = true;
    }
    }

    if(processBarOpen) {
    tmp = Time[0];
    open = Open[0];

    sqIsBarOpen = true;
    }
    } else {
    sqIsBarOpen = false;
    }

    I need to know either:-

    1. Where to insert the above code (if that is all that I need) into the source code of my EA in MetaEditor

    or

    2. Write it in SQ EA wizard

    Many thanks

    #234618
    tomas262
    Administrator
    1826 Posts

    Hello,

    you can try a simplier method. Just use the Sleep function as show here https://docs.mql4.com/common/sleep

    In EA Wizard add Other -> Custom Action before placing an order and set the parameter as “Sleep(60000);” for 1 minute delay

    NOTE: Sleep() function does not suspend execution of the Expert Advisor in the Strategy Tester

    #234636
    Customer
    2 Posts

    Many thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.