mql4 fails to recognize close

 

I've been writing a number of EAs for the last year and I'm perplexed as to why the closing of a trade frequently fails to obey the closing rule in the strategy tester. This happens even on the simplest of EAs for example using a ma crossover to buy/sell and then close when the ma crossover goes in the opposite direction. I've tried changing coding templates and even adopted the official code examples from MQL4 Tutorial with no change in behaviour.


I most commonly use the open prices only method, but it even happens when using the tick by tick. What gives?

 

Use the Print() statement to:

- See the content of key variables

- Track the flow of logic


CB

 

Weird errors are still always logical. They can always be tracked down. Usually weird errors come from places where you assume you can't make a mistake. What I do usually with these errors is comment everything that is not absolutely necessary then I start uncommenting line by line until the problems come back. Once you find the line, it's easy to fix.

.

Jon

 
cloudbreaker:

Use the Print() statement to:

- See the content of key variables

- Track the flow of logic


CB

Thanks very much for the obvious pointers. It helps to know other people arent having this problem. I did insert some print statements and voila', the problem became self evident. Thanks !