• Join us

MQL4 (in Strategy Tester) - double testing of entry conditions

To add comments, please log in or register
caesarSK
29
caesarSK  

Hi all,

I would need to double-test the entry condition in my EA. The condition is the same but I want to test its validity with a time delay.

for example:

if(OPEN_CONDITION){
        time_delay (2s);
        if(OPEN_CONDITION){
                OrderSend();
        }
}

Sleep() function does not suspend execution of the EA in the Strategy Tester.


Any idea for this?

Operation of Programs in the Strategy Tester - MQL4 programs - MQL4 Reference
Operation of Programs in the Strategy Tester - MQL4 programs - MQL4 Reference
  • docs.mql4.com
There are operation limitations for some functions in the client terminal's Strategy Tester. Calling that functions leads to error 4059 (Function is not allowed in testing mode). The Sleep() Function The Print() and PrintFormat() Functions To increase performance, Print() and PrintFormat() functions are not executed when optimizing the trading...
William Roeder
20359
William Roeder  
You are looking at a signal. Look for a change of signal, with delay.
 static bool openCondition=false; static datetime firstSeen;
 bool prevCondition = openCondition; openCondition = OPENCONDITION;
 if(openCondition){
    if(!prevCondition) firstSeen = TimeCurrent(); // Remember first seen
    else if(TimeCurrent() - firstSeen >= 2){      // Still set for 2 seconds
                 OrderSend();
         }
 // else                                          // still waiting.
 }
To add comments, please log in or register