Trades executing in visual mode but not in optimisation?

 
Any idea why my EA is clearly executing around 300 trades a year in visual mode on 3 symbols simultaneously but when I try to optimise, many iterations have 0 trades, and most are 0-10 trades with the odd one at 20ish. This is weird since the code is the same and it works fine in visual mode. Parameters are very much within the normal range.
 

Check for

#property tester_everytick_calculate
 
Alain Verleyen #:

Check for

Added it, still the same. Checked the code too, everything looks normal and seems like it should work as intended.

 
@Jack White #:Added it, still the same. Checked the code too, everything looks normal and seems like it should work as intended.

It may be that your code logic is dependant on graphical objects, which are rendered in visual mode, but they are not rendered in optimisations.

Make sure your trade code logic does not depend on graphical objects.

 
Fernando Carreiro #:

It may be that your code logic is dependant on graphical objects, which are rendered in visual mode, but they are not rendered in optimisations.

Make sure your trade code logic does not depend on graphical objects.

It doesn't. Just the standard iMA handlers, nothing too fancy. I just find it odd that there are always some iterations that are non-zero in trades. It would make more sense that they're all 0 trades or non-zero. I've had it happen with an EA I was having developed earlier too but I attributed that to not knowing the source code. This EA however is my own and I've seen it function normally. Is it possible there's a bug in MT5? There have been times in the past where I've seen MT5 show >>100% DD.

 
Jack White #: It doesn't. Just the standard iMA handlers, nothing too fancy. I just find it odd that there are always some iterations that are non-zero in trades. It would make more sense that they're all 0 trades or non-zero. I've had it happen with an EA I was having developed earlier too but I attributed that to not knowing the source code. This EA however is my own and I've seen it function normally. Is it possible there's a bug in MT5? There have been times in the past where I've seen MT5 show >>100% DD.

You will have to provide some code example that can reproduce the issue, otherwise we will just have to assume the bug is in your own code and not in MetaTrader.

At the moment, you have only vaguely described the issue. We will require code, logs and reports, to be able to test ourselves and compare, to be able to either point you to a solution or to present to MetaQuotes.

However, most of the time, the issue is normally a bug in the EA code. Only on lesser occasions can it be traced to a bug in MetaTrader.

So, if you need further advice, you will need to provide some kind of example code that can reproduce the issue, with accompanying log files tester reports.

 
Jack White #:

It doesn't. Just the standard iMA handlers, nothing too fancy. I just find it odd that there are always some iterations that are non-zero in trades. It would make more sense that they're all 0 trades or non-zero. I've had it happen with an EA I was having developed earlier too but I attributed that to not knowing the source code. This EA however is my own and I've seen it function normally. Is it possible there's a bug in MT5? There have been times in the past where I've seen MT5 show >>100% DD.

How could we know ? All is possible until proved it's not.

If you post all what is necessary someone could reproduce it and help. Otherwise you will have to find by yourself.

Reason: