Personaly I use ruby to code strategy back-tests before I even begin coding the EA.
I export the data from MT4 to a cvs file and work with that. So far this has been the fastest method "idea-backtest-optimizationOfParameters-retest-checkWithChart-codeEA". Would love to hear what other people use.
Cheers o/
EDIT: my choice of ruby boiled down to because it was fast to code with, eas(ish) to learn and perfect for little scripts, plus it has a nice IDE to work in, if you want it and very easy to read and debug. I was thinking about c++, vb, java and everything else that I was working with in the past (hell I even had an idea about MySQL database) but tbh I just wanted the first back-tests to be fast so that I knew whether to immediately discard the idea or continue working with it.
For me the MT4 tester is fast enough. I don't use the optimizer a lot, and after going to test the EA seriously i optimize the code.
Optimizing is where the speed is hidden.
1) 90% of all ticks don't need a recalculation of the indicator values and the same 90% does not even need to reevaluate the open orders.
2) Functions are very useful. But if you need to call the same function again somewhere else in your code it might be better to store the result on the first call.
3) Do only the necessary thing while testing. Error and recovery handling is not needed.
4) Print(), Alert() and every object() call slows down. Don't use them if possible
WHRoeder, can you explain your link a little bit?
I should mention too that our EA is a very complex EA. Backtesting for simple Expert Advisors isn't too bad, though it still can be slow depending on how far you want to backtest, and if your wanting to backtest with everytick. Also optimizing a complex EA would take a long time as well. So I think for many traders and developers there is a great need for MT4 to support faster backtesting and optimization utilizing technologies such as multi-threading etc.. As I see this being a demand in many forums!
Also I found something very interesting! That I want to share with you read below...
Metaqoutes the makers of Meta Trader 4 make branded solutions for brokers. So I got thinking...
I contacted Metaqoutes to ask them if they could provide me with a copy of Meta Trader 4 that can handle faster backtesting and optimization, and that could support multi-threading. I got an email back the next day
saying that would provide me with an offer. So I'm not sure how much they will charge me, but I will let you guys know as soon as I find out. But this gets me thinking... Do they already have a customized version of MT4? and if so why aren't they sharing this? Or why are they not implementing this in MT4 updates? Get's you kind of thinking..... But maybe they don't have this programmed yet, and will charge me to have this customized, but my guess is they already have a version of MT4 developed that enables faster backtesting/optimization and support for newer technologies such as multi-threading etc.. And Yes I know MT5 supports multi-threading but there is several features missing in MT5 that MT4 has and not many brokers support MT5 yet, and the EA would have to recoded.
WHRoeder, can you explain your link a little bit?
I should mention too that our EA is a very complex EA.
double minGapStop = MarketInfo(Symbol(), MODE_STOPLEVEL)*Point, SetStops(oo.SL, oo.TP, size, oo.price); if (oo.TP != TPorig){ // Handle TP double TPmin = now.close +DIR* minGapStop; if ((oo.TP-TPmin)*DIR < 0){ // Below min? oo.TP = TPmin; // Can't. CallAgain(oo.TP+stop.to.Bid -DIR* (minGapChange+Point),"mTP"); } if ((TPorig != NO_TP) && (oo.TP-TPorig)*DIR < Point) oo.TP = TPorig; // TP up only. }
- For the standard buy trailing stop, newSL=market - SL.pips*pips2dbl, you know the SL can move up only when market goes above curSL+ SL.pips*pips2dbl, so I'd have
CallAgain(oo.SL +DIR * SL.pips*pips2dbl +stop.to.Bid);
No point in checking to move the SL until market moves sufficiently. - Like wise if I determine I want to open an order at a specific price
double delta = (Bid-oo.OP)*DIR; if (delta <= 0){ CallAgain(oo.OP); return; } // Below if (delta > 0.5*atr){ CallAgain(oo.OP); return; } // Gapped above
If market hasn't yet reached there, request to be called again. extern bool Show.Comments = true; int init(){ if (IsTesting() && !IsVisualMode()){ Show.Comments = false; Show.Objects = false; }
Since objects and comments are for Human use only, I don't create any under testing.
Not sure what you want explained. My EA is over 2000 bidirectional lines, code works in either direction:
- For the standard buy trailing stop, newSL=market - SL.pips*pips2dbl, you know the SL can move up only when market goes above curSL+ SL.pips*pips2dbl, so I'd haveNo point in checking to move the SL until market moves sufficiently.
- Like wise if I determine I want to open an order at a specific priceIf market hasn't yet reached there, request to be called again.
- Since objects and comments are for Human use only, I don't create any under testing.
https://forum.mql4.com/40529#467336
extern bool Show.Comments = true; int init(){ if (IsTesting() && !IsVisualMode()){ Show.Comments = false; Show.Objects = false; }
I was wondering for mt4 b600+ how you would implement a hide comments/hide objects routine
I tried to copy this into my EA in the Initialize section and I got 2 errors:
'init' - function can be declared only in the global scope 1570 13
'init' - function already defined and has body 1570 13
extern bool Show.Comments = true;Since build 600, variable names can not have dots.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Greetings! : )
I know there has been a few postings asking how to speed up backtesting an EA in MT4. I have searched through this forum and others to see what solutions there might be. I have not found any good solutions. However if I missed something please let me know. Most of the posts about backtesting that I have found seem to be a bit old dating a few years mostly from 2008-2009. If we may, let's come together and post possible new solutions for this age old problem.
p.s read the 5th post below after reading this... I have some updated information I think you'll find interesting...
So I wanted to repost this and keep this post active with new information, and new ideas! Where we are in the year 2011 I'm hoping there is some better/new solutions available than there was a few years back. So I'd like to ask some of the following questions. I have an EA that is somewhat complex, is there any way to speed up backtesting in MT4? There's got to be a good way to back test an MT4 EA. I wish it would utilize more processing power of my computer, but MT4 only uses about 10-20% of my EA. I understand MT5 supports multi-threading, and is supposedly is faster? But again my is EA is programmed for MT4, and I wouldn't want to recode the EA. I understand I could also program the EA in something like C++/C# etc.. But I that would require reprogramming it. Is there any programs out there that backtest EA's outside of MT4? Where I could just import my mql4 file? Because I don't want to have to recode the EA. There's just got to be some solutions out there! Please contribute to this thread : ) *The questions above could also apply to optimization as well, though I think the problem relates to both optimizing and backtesting since they are similar.
So maybe we can post past common known ways to speed up the EA. (Though in my opinion none of these tend to speed it up much)
*Download historical data - from my experience this doesn't speed it up too much..
*Go to options and charts and put change the "Max bar history" to 9999999 etc..
These are the only two methods I know of that people have suggested, but they don't seem to speed it up much. If I am missing any other please let me know. I'm running this on a Quad Core Windows Server 2008 machine. With 8 gigs of ram. The other solution someone has said is to program it for Mql5 or program it as a separate program outside of MT4. But I don't want to have to recode the EA, I wouldn't want to loose some of the logic in translating it into a different language.
So please any input would be great! : )