Simulation Setup for MT4 Expert Advisor
These are a few issue that I discovered when simulating with MT4 using History data. As the quality and accuracy of the history depends very much related to your trading strategy indicator and stoploss & profit taking.
a) Simulating M1 period result seems to yield the most accurate results from your EA. If you are using period H1 or any other period indicator or measurement of time, please replace 0 with PERIOD_H1 or any other time frame. Don't use in the strategy tester period H1, as the results will not be accurate if you plan to compare with real result. Therefore, use period M1 in your strategy tester. And modify your EA to run on in.
b) Downloading M1 result and using period_converter for 5, 15, 30, 60, 240, 1440 minutes will be getting more accurate results rather then just download and import M1 result from the internet. This will synchronize all other time frame with M1 as the base. The most realistic result you can get is from M1 timeframe, thus all other timeframe is actually using this M1 base. You can download from any internet website that provide time frame M1 from 2001 till date.
c) In order to use the strategy tester in MT4 platform, you need to declare
static datetime nextRund
if( nextRund > TimeCurrent() ) return(0);
nextRund = TimeCurrent() + 30;
The above will step thru your Period M1 and your Use date from yyyy.mm.dd to yyyy.mm.dd As the program automatically increment 30 seconds into nextRund (just a name datetime variable) and cause the if statement to exit the program via return(0). Which will exit the program or looping function (also eventually exit the program), and cause the strategy tester to step the TimeCurrent() to next period M1. During the tester, the TimeCurrent() will be simulated from start to end. As the program will exit, so all your variables that need to be valid (stay in memory when your program exist and execute again), please indicate static infront. This will enable that variable to be able to be use again (retain previous value) by the program.
You may need some times to understand the above, but read thru and try it out on the EA and you will learn how to use the above to your advantage.
d) Delay is not applicable to the strategy but you can use it freely on your EA while running live account. But using it in your EA to delay your looping or program while waiting for new live currency price is useful if you plan to run multiple currency using multiple strategy. Play around with different delay and you will notice the utilization of your CPU averaging over time instead of peaking at one point.
Please go try and use the above to improve your EA.
Have a question for Sng or want to leave a comment?