Reply

Delay order send by x minutes

2 replies

David Fox

Customer, bbp_participant, community, 0 replies.

Visit profile

5 years ago #234616

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

0

tomas262

Administrator, sq-ultimate, 2 replies.

Visit profile

5 years ago #234618

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

0

David Fox

Customer, bbp_participant, community, 0 replies.

Visit profile

5 years ago #234636

Many thanks

0

Viewing 2 replies - 1 through 2 (of 2 total)