I wonder whether someone could help me.
I have written, what I consider to be a very simple EA but when trying to back-test this EA using MT4, the backtester seems to work for a few trades and then 'stops' (by running to the end without placing any further trades).
It is almost like it runs out of memory, but I do not know how to check whether this is the case.
As an example, if I want to back-test the code from the 1st of Jan 2016 to today, it might place a few trades in January up to say the 10th of January and then it suggests that it won't place any other trades for the rest of the year, but if you were to set your start date to later in the month, it would place trades.
Could anyone suggest what the issue could be please, as this is driving me crazy.
Leon Lodewyks: I wonder whether someone could help me.
You will have to post your code if you want us to be able to help you. We can only guess at what the problem can be.
Alain, mentioned lines 128 and 278, but I think he was just joking in order to make the point that we can only guess to what the problem can be because you have not provided any code to look at.
However, also make sure that you actually have history data available for the period in question that is being tested.
haha...thank you! I completely missed the joke :)
I'll paste the code, I thought it may be a generic MT4 error, so I didn't post the code.
Sorry - here is the code.
I have downloaded tickdata and tried that, but also just by downloading the data through the history centre. Both, the same behaviour.
Where do I start???? There are so many problematic areas I am not sure even which is the culprit or the culprits, but the first thing I noticed was the several lines where you use "variable == Bid" or "variable == Ask".
This will cause many a problem, because there is no guarantee that a price will exactly match. You should use a ">=" or "<=" depending on the situation.
As for the rest, I have not analysed properly yet. Try to fix this first and test it before we look at it again. Then post the new code once you have done that.
Also, what is up with the "Time_open = TimeCurrent()-Time;" and the "(TimeCurrent()- Time)<Time_open)"? It will get to a point when you could get a difference of Zero (or one, or a very small value) and then you will no longer be able to place orders.
EDIT: Reconsidering this situation, this is probably the main culprit for your problem.
This was actually some code I took from the below to prevent the EA from trading more than once in the same bar.