how can an EA slows down its speed in the startegy tester - visual mode - intelligently?

 

Hi,

may be s.o. here knows an intelligent way that an EA slows down its speed in the strategy tester.

I know you can slow down the execution speed manually by the sliding bar beside the 'Visual mode' - but I want the EA to do this by it self!! (Why do I have a computer and a program if I have to do everything myself?)

The EA will recognize the proximity of a special situation and then it should slow downy it's speed.

Normally one would use Sleep(..) but Sleep doesn't work in testing...

Next thought would be a loop:

int nLoop = proximity(..);
while(nLoo>0){ nLoop--; 
        /* do s.th. time-consumig <= any idea ?? */
}

But what can I put in that loop which is a bit more intelligent ans time consuming than x=5;

My mind is blocked. Anybody with an idea?

Thanks a lot in advance!

Gooly

 
gooly:

Hi,

may be s.o. here knows an intelligent way that an EA slows down its speed in the strategy tester.


The only intelligent way is to use an WinAPI call of some sort to move the speed slider . . . anything else is a kludge. Yes, I have used the kludge before, but it's not nice.
 

may I ask what didi you do?

s.th. graphical, array-copies, ..?

 
if(condition) PauseTest() from my code
 
WHRoeder:
if(condition) PauseTest() from my code

AHHH!


Thank you very much, WHRoeder!!

Gooly

 
gooly:

may I ask what didi you do?

s.th. graphical, array-copies, ..?

Just a long loop to burn CPU cycles . . .
 
int wait = GetTickCount()+1000;
while(GetTickCount() < wait)
{
 //waiting 1 second
}
i havent tested that in strategytester
 

Again, Thanks to all of you.

The solution of WHRoeder calls a function from user32.dll: PostMessageA(..) and this seems to have an 'internal' sleep.

Now in kernel32.dll there is the Windows-function Sleep. Look here, it seems to be a good overview:

http://pinvoke.net/search.aspx?search=sleep&namespace=[All]

Has anybody tried to use the origin Windows sleep?

The problem might by that sleep generally 'sleeps' the mt4 (all its charts) and not only the chart of the start.-tester - correct?

Can't there exist a way to sleep only the start.-tester-chart?

Gooly

 
gooly:

Again, Thanks to all of you.

The solution of WHRoeder calls a function from user32.dll: PostMessageA(..) and this seems to have an 'internal' sleep.

Now in kernel32.dll there is the Windows-function Sleep. Look here, it seems to be a good overview:

http://pinvoke.net/search.aspx?search=sleep&namespace=[All]

Has anybody tried to use the origin Windows sleep?

The problem might by that sleep generally 'sleeps' the mt4 (all its charts) and not only the chart of the start.-tester - correct?

Can't there exist a way to sleep only the start.-tester-chart?

Gooly


There indeed is Sleep() in the kernel32.dll. But you will not be able to call this function directly from recent MQL4, because it is already declared.
 
Ovo:

There indeed is Sleep() in the kernel32.dll. But you will not be able to call this function directly from recent MQL4, because it is already declared.

And this won't change in the new version? I guess when I saw this: https://www.mql5.com/en/docs/common
 
WHRoeder:
if(condition) PauseTest() from my code

This works so far, but there seems to be a minor little problem.

if(condition == true)..

I see that the stop and go button is changing all the time. It's ok for me if it works that way!

But then it remains at stop after the condition fails again and the speed should be high again.

So I changed your PauseTest() so that

1) the slow-speed can be changed dynamically

2) one can choose whether to stop or to continue..

(I hope you don't mind!)

// usage: if ( secLeft > 0 ) PauseTest(200/secLeft, false);
void PauseTest(int loop=200, bool stop=true ){   datetime now = TimeCurrent();   static datetime oncePerTick;
    if (IsTesting() && IsVisualMode() && IsDllsAllowed() && oncePerTick != now){
        oncePerTick = now;
        loop *= 1000 ;//200000;
        while(loop>0){loop--;
            int main = GetAncestor(WindowHandle(Symbol(), Period()), 2 /* GA_ROOT */);
            if (loop==0) PostMessageA(main, WM_COMMAND, 0x57a, 0); // 1402. Pause
            if (loop==0 && !stop) PostMessageA(main, WM_COMMAND, 0x57a, 0); // 2 calls to have prev status
    }   }
}

gooly

Reason: