Expert Advisor works in the strategy tester as expected, but not on the live account

 
Hello,

I have written an EA that should trade 36 symbols of the market watch at the same time. This works in the strategy tester exactly as expected, so it executes exactly the program. However, when I want to run the program live in the demo account, it stops at a certain point. Basically, the execution of the program is also much too slow. Every tick, all symbols should be evaluated, which should be in the range of microseconds (if you take the required computing time in the Strategy Tester as a basis). However, if the program is executed live, the processing of the For loop takes an incredible 30 seconds (I can count every For by hand, that's how slow it is executed), in the strategy tester the execution is extremely fast, as you would expect.


So I think that the program is not executed correctly because of the extremely slow execution, probably the "ticks" come in faster than my program can go into the next "mode" because the For loop is executed so extremely slow (30s instead of a few 100 microseconds).

Can anyone give me a sound answer to this question?

Friendly greetings

Paul



Another note: an earlier version of the program, which is not quite up to date, only executes 3 icons, but seems to work correctly.

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
 
It's probably something in your code because i have no issues analyzing 40 currency pairs in a fast millisecond timer.
 
Marco vd Heijden:
It's probably something in your code because i have no issues analyzing 40 currency pairs in a fast millisecond timer.

If I make a Profiling-Test it shows me two different things. In the Live Account the time is spend on copy buffer, but that seems to be no problem in the strategy tester.


Pictures

Strategy-Tester:

https://www.bilder-upload.eu/bild-d18e16-1579513272.jpg.html


Live:

https://www.bilder-upload.eu/bild-138b28-1579512841.jpg.html
Bilder-Upload - Kostenlos Fotos hochladen und ins Netz stellen
Bilder-Upload - Kostenlos Fotos hochladen und ins Netz stellen
  • Michael Heiter
  • www.bilder-upload.eu
Kostenlos Bilder hochladen. Bilder Upload ohne Anmeldung
 

If you can post the code we can have a look.

Without code there is little we can do.

 

I don't know if it could be related. I had big problems when symbols in the MW window do not have enough data.

Link

Using CopyBuffer with the symbols without enough history totally crashed my platform.

iBars() takes forever
iBars() takes forever
  • 2019.12.12
  • www.mql5.com
Build 2190 My platform was crashing when I ran my code...
 
Marco vd Heijden:

If you can post the code we can have a look.

Without code there is little we can do.

It has the form:


double Array1[];

double Array2[];

...

...

...

double Array10[]


OnTick{

For{ for all Symbols (36)

Code:

ArraySetAsSeries(Array1)

ArraySetAsSeries(Array2)

...

...

...

ArraySetAsSeries(Array10)



CopyBuffer(Array1,50)

CopyBuffer(Array2,50)

...

...

...

CopyBuffer(Array10, 50)

}//For

}//OnTick

It works on strategy tester but it spend all the time in CopyBuffer if the thing is live.

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
The idea of ​​automated trading is appealing by the fact that the trading robot can work non-stop for 24 hours a day, seven days a week. The robot does not get tired, doubtful or scared, it's is totally free from any psychological problems. It is sufficient enough to clearly formalize the trading rules and implement them in the algorithms, and...
 

Okay so you are running the calculation on every new tick for the chart instrument.

A better way would be to leave the OnTick() function empty and use a fast timer.

EventSetMillisecondTimer(500);// in OnInit() function

OnTimer()
 {
  // Your code here...
 }
 
Marco vd Heijden:

Okay so you are running the calculation on every new tick for the chart instrument.

A better way would be to leave the OnTick() function empty and use a fast timer.

That sounds like an idea. I will try this 

 
DasUnding:

That sounds like an idea. I will try this 

I have tried it. It also spends the time in the CopyBuffer prozess. Overall that are only 36*50=1800 copies but it needs 30s?

 
Maybe you reduce the amount of elements and calls.
 
Marco vd Heijden:
Maybe you reduce the amount if calls.

But why is it fast in the Strategy-Tester and slow Live? Even if i calculate a year it only needs 1.5h for every tick which means I am in a microsecond range for the Live-trading but in fact it needs 10^6 times more time Live?

Reason: