You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Good post about backtesting, bid/ask price:
https://www.mql5.com/en/forum/181204
Strategytester: LotSize Limit MT4
Hi,
How can I change the maximum Lot Size settings in MT$ strategy tester? Atm the Strategy Tester Wont open up Potisions >50 Lots.
and is there a Balance Limit in the Strategy tester?
Would Appreciate some help. Thanks!!
Some decent data that I've used came from here:
Http://www.histdata.com
Cheers!!Thanks for the advice...im useing tickdata from Ducas with 99% modling quality atm. I cant quite say, how close this get to reality, but i hope its close enough ^^
[langtitle=fr]Probl�me sur un backtest[/langtitle]
[lang=fr]Bonjour tout le monde,
Je me tourne vers vous car j'ai un probleme lors du backtest de mon EA.
Comme vous pourrez voir sur le graphique, il y a une chute brutale et je ne sais pas d ou ca vient j ai un stop loss regler sur 10 pips
Normal End Of Tester Stop Out
[lang=fr]Bonjour tout le monde,
Je me tourne vers vous car j'ai un probleme lors du backtest de mon EA.
Comme vous pourrez voir sur le graphique, il y a une chute brutale et je ne sais pas d ou ca vient j ai un stop loss regler sur 10 pipsHi Targetik,
That is a normal "End Of Strategy Tester" Stop-Out...
The tester closes out all open trades when the tester ends...and all your active open trades usually close with a loss.
I just ignore the last trade...or I re-set the dates to go passed that trade so it can close properly...or I set the date of the last closed trade so I don't have any open trades at the end of the testing.
Hope this helps,
Robert
[lang=fr]Merci beaucoup [/lang]
Great Thread!
--
Retrieve highest equity from optimizations?
Is it possible to retrieve information on the highest equity reached by each run through of any given set of optimization results in MT4?
As far as I can tell, MT4 does not provide information in the results window for the highest equity reached by a strategy during back testing - either in the optimization results or in the report from a single manual run through. (The closest it gets is the drawdown $, which I think requires you to know the value of the relevant trough to determine what the previous peak was - and you can only guess at that from the end balance). Presumably the strategy tester would have known that exact highest equity figure at some point during its calculations. Is there any way of retrieving that data for optimization results?
I can think of a partial work around. The highest equity reached during a single manual back test could be seen by adding a variable in the EA which acts as a record of the "highest water mark" reached in terms of equity, and then printing that to the journal at the end of the run through (or whenever). The problem is that journal information does not seem to be available when the same strategy is run as part of an optimization... This would be fine for a small number of manual run throughs, but not suitable for a larger number of optimizations.
The only other work around I can think of is to use an indicator which acts as an EA, and load it in to the normal terminal chart. By inputting a "start time" as an external variable it could keep a tally of profit and loss (as long as positions are not opened inside candlesticks). The problem with that is the same however. You would still need to manually type in the different external variables for each different run through of the optimization possibilities - which could be many!
Alternatively, you could place an artificial cap on the equity in an EA, and then close all positions and end the trading in the EA once a predetermined equity had been reached. Then you would be able to see a list of the number of run throughs which ended on that value in the results of the optimizations. However, you would not know from this whether any given run through would have gone on to reach a higher equity unless you run a large number of run throughs with different equity caps. This seems like a very clumsy and inefficient work around though.
(Even being able to see a simple chart of the balance vs. trade number would be a start - but that doesn't seem to be available from the optimizations either).
Does anyone know of a better method which would work more efficiently for optimizations?
I think I just found the answer to my own question, so I shall post here in case anyone still wants to know the answer.
One solution is to use global variables (Global variables - MQL4 Documentation). As it turns out, global variables ARE set or updated during each run through of an optimization. I am referring to the client terminal wide global variables here, not just the "global variables" within an EA. Since the variable is global, you can then query it using something outside the Strategy Tester. You could simply add a normal (double) variable inside the EA which updates itself to the highest ever equity every tick, then set a global variable to that value in the deinit() section of that same EA. This global variable could then be queried using GlobalVariableGet() in a script on a normal chart window in the terminal once each pass of the optimization is completed, and the resulting value could be displayed as a Comment or recorded in the terminal journal using Print.
The only problem with this approach is that you would have to manually run the script after each run through of each pass in the optimization (before the next run through completed) - so you would still need to sit and watch the optimizations. I do not think an EA could be used to query the global variable, because the EA would need to run multiple times to capture multiple run throughs of the optimization. It is most likely that you would not be receiving any ticks during an optimization, because you would be disconnected from live data in order to preserve your spread settings. I'm guessing the various methods of sending "fake ticks" to the EA would not work FROM an optimization run through TO the normal terminal chart...
This is less of a problem if you are using an account with a stable spread size, in which case you could run optimizations while connected to incoming live data, without too much of a risk of changing the spread data. It would still be a problem if you wanted to optimize over the weekend though. Also, if your next optimization pass completed before a new tick was received then the data from the last pass would go unrecorded.
You could get around this by setting a SEPARATE global variable with each pass of the optimization, and then read them all off at the end by pressing F3. That could be done with a cycle operation in the deinit() to retrieve the current number of global variables ("n"), and then name the current global variable "n+1", and set it to the relevant equity value. That way you could view them all at the end by pressing F3, and the name of the variable would be the same as the number of the pass of the run through (as long as there were no global variables in existence at the start of the optimization - which can easily be achieved by running a script with GlobalVariablesDeleteAll() before each optimization). I'm not sure what the maximum number of global variables is - but as long as you have a reasonable number of optimizations it should be fine I guess. Unfortunately I don't think the data from pressing F3 is exportable, so you would have to copy it down using a screen cap or good old pen and paper (or just have a separate MT4 installation for each optimization if you are using a stupendous number of passes). I suppose you could alternatively write a script to then Print all the names and values of the global variables to the terminal journal after the optimization is complete, and then export THAT journal.
This method could of course then be used to retrieve just about any data from optimizations, instead of having to rely upon the limited information of the Strategy Tester optimization results window! Hope that helps someone :-)
p.s. - I've just realized that both Print and Alert only allow 64 characters, so you could not write a script to Print the global variables if you were using more than a handful of optimizations. (Unless you printed each global variable in a separate line of the terminal journal, and then clicked and copied them all one-by-one over to excel or similar. There does not seem to be a way to select more than one entry in the journal at any one time).
The get around this, you could instead use a cycle operation to write the values of each one of the global variables in sequence on to a massive string (using \n to place each global variable value on a new line), and then email that string to yourself using SendMail(). There does not seem to be a limit on the number of characters in Send Mail. You can easily copy this email data to a text document on your computer, and use the Data\Import External Data\Import Data button in excel to import that data in whatever format you want. If you also copy the optimization results to a text document, and then import them to excel using the same method (selecting "Delimited" in the first screen, then ticking the box for "Other" and typing "=" in that input box in order to separate the text from the numbers), you can then simply line the data from your email up to the data exported directly from the optimization. That way you will have whatever information you extracted from the optimization using global variables in the same row as the relevant data exported from the optimization for any given pass. Simples.