how does the optimizer work?

To add comments, please log in or register
gatornuke
355
gatornuke  

Ok, so i'm now in the "sensitivity study" phase of my development, and i thought i'd use the "optimiser" in the backtest to help me out. Basically i'm checking for optimum operational modes of my EAs, (e.g. multiple orders vs single order, hedging vs not, etc). Instead of running the backtest for a couple of days on a given configuration, saving the results for later analysys and moving on to the next configuration manually, I thought i'd have the optimizer do it for me. I thought that if i set the sequence of modes i'm interested in testing i could just leave it alone for a week or two and come back to it and collect the results. This would make it less manually intensive and easier to keep track of what i'm doing, too.

This all sounds great, but the problem is that the "optimization results", "optimization graph", "results", and "graph" tabs are completely empty after running for a day. Normally by now i can see the first few trades on the "graph" and "results" tab.

My question is this: Does the optimizer run like an automated sequence of backtests in series like i thought (showing results along the way) or does it run everything internally and then spit out the answer once it's completely done? I guess i could stop it and run each backtest individually, but i'd hate to kill it if it's actually doing something.

bernd
989
bernd  

gatornuke:

My question is this: Does the optimizer run like an automated sequence of backtests in series like i thought (showing results along the way) or does it run everything internally and then spit out the answer once it's completely done? I guess i could stop it and run each backtest individually, but i'd hate to kill it if it's actually doing something.

It will insert a new row into the optimization results table as soon as one backtest is finished and it moves on to the next combination of input parameters. You wont see anything before the first backtest is done, it wont show things that happen *during* the backtest. I suggest making yourself more comfortable with the optimizer by trying it first on a more simple EA like the MACD example that does not take hours or days for a single run.

Also there is a setting on the results page to "hide irrelevant results" (I have no idea what MT4 considers irrelevant, I have always turned this off).

You could also make your EA log to a file (or to the debug monitor (OutputDebugString/DebugView.exe)) from time to time (for example once in init() and after each trade) so you can see whether it is actually doing something and is not caught in an infinite loop somewhere in your code that happens only with a certain combination of parameters.

forexhunter100
8
forexhunter100  
7bit:

It will insert a new row into the optimization results table as soon as one backtest is finished and it moves on to the next combination of input parameters. You wont see anything before the first backtest is done, it wont show things that happen *during* the backtest. I suggest making yourself more comfortable with the optimizer by trying it first on a more simple EA like the MACD example that does not take hours or days for a single run.

Also there is a setting on the results page to "hide irrelevant results" (I have no idea what MT4 considers irrelevant, I have always turned this off).

You could also make your EA log to a file (or to the debug monitor (OutputDebugString/DebugView.exe)) from time to time (for example once in init() and after each trade) so you can see whether it is actually doing something and is not caught in an infinite loop somewhere in your code that happens only with a certain combination of parameters.


sometimes you also might have a gaps in your history data

so you maybe run your expert with blank days

gatornuke
355
gatornuke  

Thanks a lot guys, at least now I know it's actually doing something. I don't think i'll kill it at this point for output logging, but i'll probably do that on the next run. I'd say it's about 5-10% done at this point and i'd hate to have to start over. This might take a few weeks. I'll probably play around with the optimizer on a parallel session with a simple EA like 7bit mentioned just to get acqainted with it. I never really paid much attention to it before since i actually want to make money, not just curve fit history data. It appears it might come in handy for this type of sensitivity study, though.

My computer's been running at 100% CPU utilization on all cores for quite some time now. i'm surprised it hasn't caught on fire yet. It may be time to invest on some new hardware...

zzuegg
1504
zzuegg  
gatornuke:


My computer's been running at 100% CPU utilization on all cores for quite some time now.

AFAIK mt4 can only use one (1) core.

Ray
2653
Ray  

I have an i7 (8 logical cores), MT4 maxes out at 12% usage on TaskManager, 1/8th of 100%, though it does seem to not be entirely confined to one core, it apparently isn't able to utilize more than one at any particular time...

bernd
989
bernd  

If the EA spends most of its time in external library calls like for example a neural network library that was designed to split the workload into several threads then this might lead to better utilization of the available CPU cores.

MT4 itself will not start more than one thread for the backtest, so if the EA itself does not actively start multiple threads itself then it will use only one CPU.


If the backtest would take a week and the EA is single-threaded and there are multiple cores available it might be a good idea to start as many instances of the terminal as there are CPU cores and split the parameter space into equal chunks and run them all at the same time.

bernd
989
bernd  
during normal operation MT4 will start a new separate thread for every call of the start() function so running multiple EAs on multiple pairs should utilize all CPU cores equally.
gatornuke
355
gatornuke  

I have several other instances open backtesting different variants of my Monte Carlo-based EA (hence the multiple core utilization). This latest optimizer-assisted backtest is running on 60,000 bars (after >650k bars history is collected), and it's running 1,000 samples per bar, in a sequence of 6 alternate operational modes, so that's about 360,000,000 random samples, plus statistical analysis over accumulated history on each bar and other computational overhead. I decreased the number of histories so the backtest could finish within a reasonable timeframe of weeks, rather than months or years. During live deployment i'd like this thing to run many more histories per bar than that.

7bit: That's very intersting, I'm glad that if I'm runing an EA on different pairs it's not necessary to have multiple instances of MT4 open.

whroeder1
17945
whroeder1  

gatornuke:

My question is this: Does the optimizer run like an automated sequence of backtests in series like i thought (showing results along the way) or

Yes but won't show loosing combinations unless you optimized results tab -> right click -> show useless results.
gatornuke
355
gatornuke  
WHRoeder:
Yes but won't show loosing combinations unless you optimized results tab -> right click -> show useless results.

ah, i see...
12
To add comments, please log in or register