Out Of Memory Exception in Optimizer but not in Strategy window
Author: Assenzio
Creation Date: 2/7/2011 5:00 PM
profile picture

Assenzio

#1
When I try to use this code, following standard parameter, during the optimization method (for exit and entry parameters only) WLD crashes with the "system.outofmemory" error. I need to perform just 456 runs that could be usually done in less than 2 minutes. If I use "manual" optimization, moving left/right with the exit parameter for example, everything works fine. With multi signal parameter at "on" (@0), also, optimization works fine but not with mutiple signal at "off" (@0). I think the problem should be there, in that parameter I mean. How to use it correctly in the script so to not have any WLD crashes ?

CODE:
Please log in to see this code.
profile picture

Cone

#2
What kind of optimization are you running? An exhaustive opt. requires 76,222,080,000 runs!

It looks to me like Multiple == 1 causes a runtime error. By simple inspection (no time to look at this today), I would have thought that Multiple == 0 would be a problem since you're modifying the loop index bar within the loop.

Anyway, you're doing something we absolutely say not to do: creating trades on bar + n, where n > 1. Results may be unpredictable.
profile picture

Assenzio

#3
I do not have so much Runs. Runs are, as stated previously, less than 500 since I optimize ONLY Exit periods and, sometimes, Entry periods. The use of Mutiple, yes, modify the bar loop 'cause I ... want that! This code is not intented as a trading system but to measure "offline" what happened after some pattern or macro events. I use mutiple == 1 when I want to test all signal, in the previous case, on all dates that comes in the file been readed (I do not have any runtime errors). I use multiple == 0 when I don't want mutiple trades that born during an already opened position. For example ... I want to test what happened, i.e., 45 bars in the future (trade life) historically when the S&P500 ROC at 12 crosses 10%. If I want to test all trades that pup up I will use multiple == 1. I Use multiple ==0 if I don't want that other trades pups up during the holding periods of 45 bars (exit time). Is there a way to better write down this in the loop to prevent optimization crashes ?
profile picture

Eugene

#4
What optimization method are you using when it crashes? Do you run concurrent optimizations?
profile picture

Assenzio

#5
I use only the Exhaustive method, with manually elimination of unuseful parameter (almost all, I use only Entry/Exit periods). I think it's a sort of runtime error but if you optimize manually (working manually on the parameters, i.e. exit periods on the sliding bar) does not crash or gave any runtime error. Sometimes I have optimization's estimate of just 3 sec but, after I press Begin, optimization doesn't start at all and WLD crash 30/40 sec later.
profile picture

Assenzio

#6
No suggestion ? In these day I run also other optimization and sometimes the process goes trough (optimizing entry and exit parameters) but, at the end, I have 0 trades in many (90%) combination (not all). But if I use the same combination, manually, I obtain the trades. I cannot understand where could be the problem, maybe in the buy/sell loop or ... do I have to "free" memory in the code ?

For example, try to optimize this code as is, using NKY (Nikkei 225) simbol. With this setup the process should plot, as a primary series, the ratio between NKY and MXWO (MSCI World), find where the year start and try to find the best seasonal combination buying "Entry" day after the beginning of the year and "Exit" after any other trading days. The optimization process works (around 15min) but many results are 0 trades, that is impossibile changing parameters manually !

CODE:
Please log in to see this code.
profile picture

Eugene

#7
On this code:
CODE:
Please log in to see this code.

Here's something you need to know. To speed up optimizations, Wealth-Lab loads symbol's data only once and then keeps using it for each optimizer run. Therefore modiyfing the Bars object might have undesired effect in optimizations.
profile picture

Assenzio

#8
Okay, this is a very important point Eugene, thank you. Maybe using the Bars.Cache.Clear() at the end of the strategy loop could help to clear the internal cache that stores DataSeries and free memory ?

Any other hint that could affect my script in optimization ?
profile picture

Eugene

#9
To tell frankly, I'm unable to duplicate the out of memory issue on a 32-bit operating system with the memory loaded by other apps using the unmodified script (just removing the unused parameters).
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).