FAQ: "Help - Why isn't my MT4 Expert Advisor (EA) working?"

General discussion about the Tickstory Lite software package.
Post Reply
tickstory
Posts: 4883
Joined: Sun Jan 06, 2013 12:27 am

FAQ: "Help - Why isn't my MT4 Expert Advisor (EA) working?"

Post by tickstory »

Hi all,

There seems to be numerous requests from users to assist with trouble-shooting why their EA won't work. The reasons for an EA not trading, not trading as expected, giving errors or spurious results can be endless - such is the nature of a computer program. Given the complexity and time-consuming nature of trouble-shooting these sort of problems, we unfortunately can't assist in these circumstances (as much as we'd like to). This post is intended to give a general guide to assist you trouble-shooting your EA problems.

First and foremost, ensure you are getting 99% modelling quality on your back-test. Do this by back-testing with the standard "MACD Sample" EA. Completing this step successfully means that you have got your basic setup correct, including:
a) Having exported the data to the correct MT4 data location.
b) Having correctly launched MT4 with Tickstory.

If you are having trouble obtaining 99.9% modelling quality, please consult these links:
- Video primer: https://youtu.be/084k9fJCeCY
- FAQ: http://tickstory.com/forum/viewtopic.php?f=2&t=613

Here are some common questions that may follow once you start back-testing your own EAs:

Q. Why is my EA not trading?
A. An EA may not enter a trade for numerous reasons, depending of course on what entry criteria it uses and whether any errors are occurring while attempting to enter a trade. Quite commonly, EAs are dependent on the current spread of the market. If it's too high, the EA will refrain from trading. In most EAs, the spread limit is a configurable parameter and you can try adjusting this value to a higher threshold, just to see if this encourages the EA to open a trade.
Other reasons for an EA not entering a trade can often be found by analysing the tester's "Journal" tab which often contain informational messages and may be reporting error numbers during the EA's operation. These error numbers can be Googled to find out more about the nature of the problem.

Common errors are:

Order Send Error 131 (ERR_INVALID_TRADE_VOLUME) - This usually indicates that the lot size that the EA has specified is incorrect. Check the 'Lot step' parameter you have set in Tickstory when you exported your data. If the lot size that your EA is using is not a multiple of this number, you will get this error and need to modify your EA so it correctly "normalises" the order volume so it conforms. In some EAs, there is a "Lot size" parameter which can be set. In this case, make sure that your lot-size is a multiple of the "lot step" parameter.

Order Send Error 134 (ERR_NOT_ENOUGH_MONEY) - This one means that your account cannot open the requested trade due to lack of money. You can adjust your initial deposit settings in MT4 Strategy Tester to supply your EA with additional funds for the back-test (or you can try lowering any parameters in your EA that deal with risk or lot-size).

Order Send Error 129 (ERR_INVALID_PRICE) - This can occur when your EA tries to enter a trade at a certain price, but the market price has since changed. In this case, putting a "RefreshRates()" call in your EA just prior to entering a trade can resolve this problem.

Zero-divide error - This error can occur if the EA is trying to use a particular parameter (Lot size, for example) and the value is zero. Just review your EA for where this error is occuring. Once you have established which specific parameter is zero, ensure that you have correctly exported this value in your Tickstory "MT4 Settings".

Q. Why is my trading system behaving differently when using Tickstory data (as opposed to MT4 broker data)?
A. The nature of tick-quality back-testing means that you are highly likely to get markedly different results between Tickstory and your broker data. This is especially true if your EA is a "scalper" that is sensitive to small price movements. Just remember that the most granular information MT4 brokers offer you is 1-minute data. In this one minute, numerous tick prices would have normally come through to your EA in a live trading environment. With Tickstory data, this information is more accurately simulated, potentially causing your EA to behave quite differently. For longer-term strategies, these differences should be not as pronounced, however for a short-term scalper strategy, this can mean the difference between success and failure! This is why tick-backtesting can be much more revealing and valuable in assessing the viability of your strategy.

Q. I believe there's a bug in Tickstory because my EA is not operating as I expect.
A. Just remember that Tickstory only exports data - it does not perform any back-tests, calculations or the like. There are essentially 4 places where you should look when attempting to debug your issue (in order of priority):
1) Bug in the EA: Ensure your code is not being subject to some sort of bug that is causing your trading issue. Place plenty of log entries in the code to see where the issue may lie. You should also utilise the "Visual mode" of the strategy tester which may give some hints as to why your EA is entering or not entering a trade.
2) Check your MT4 Settings: Ensure you have exported the correct "MT4 Settings" for the symbol you have exported. Make sure, for example, that the 'Lot size' property has been set correctly.
3) Known MT4 issue: In some cases there are known issues with the Strategy Tester. The Tickstory & MT4 forums are often a good place to read about issues that people have come across. Examples of such issues include the "4GB FXT limtation" which limits the maximum period you can test in the Strategy Tester at one time. Other similar issues do exist, and often will have some workaround which will allow you to continue your back-testing with this issue in mind.
4) Bug in TIckstory: In the event you believe there is an issue with Tickstory, the implication is that Tickstory has exported incorrect data in some way. For example, perhaps you believe the "Open" price of a bar is incorrect. In this event, please clearly demonstrate this with screenshots of the charts and/or Historical Data Center so we can investigate further. Please do not just provide us with a copy of your EA and ask us "What's wrong?", as we are unlikely to be able to assist since understanding your code and further debugging could take many hours of our time. Instead, distill as much information as you can that allows us to work with the data itself. If, for example, your moving average indicator is giving you the incorrect value, this should easily be demonstrable by showing the incorrect data points versus what they should be. This sort of targeted information is invaluable for us to investigate and identify any issues as soon as possible.

We will be adding more information to this FAQ as we come across more questions. If you have any additional information that you would like us to add, please let us know!

Post Reply