Optimization: launched backtest runs with inconsistent parameters
Author: ronc
Creation Date: 11/20/2013 10:44 PM
profile picture

ronc

#1
After an optimization on a single symbol, I select the highest performing row based on my metric. If I double-click that row in the Results tab then a backtest runs with the parameter values from that row, but other times it seems to run with the default parameters from the code. Of course if I right click and assign preferred values to the selected symbol from that row I can run the backtest with values from that row. But how do get the backtest to run with those values without setting them? It seems that WL does do this sometimes (backtest with parameters from the double-clicked row without setting preferred values) but I cannot figure out when it does vs. when it does not...?
profile picture

Eugene

#2
For me, a backtest launched from the Results tab always runs consistently regardless to chosen parameter combination. What am I doing wrong?

How exactly are the strategy parameters defined in the code? Are PVs enabled? Maybe you did click "Save Parameters"? More details required.
profile picture

Eugene

#3
ronc wrote in a trashed duplicate thread:

(Sorry if I posted this before; searched and cannot find such previous post).

I run a genetic optimization on a single symbol, in Raw Profit mode. I sort the results on the metric of interest. Then I want to run a backtest with the best parameter set. The Strategy has no preferred values set. Sometimes, if I double-click on the row, in the optimization > results tab, the backtest runs with the parameters from that row (those params show up in the Strategy Parameters) window in the lower left. Other times, when I double-click such a row, the backtest runs but the parameters in the lower left corner remain with the defaults from the strategy, and to run a test with the params from the optimization I have to right-click and set them as preferred values. Under what conditions will double-clicking the params run the backtest with those params, without setting them as preferred values? This has me completely stumped.
Thanks,
Ron
profile picture

Eugene

#4
Please see my questions above.
profile picture

ronc

#5
Answers to the questions above:

QUOTE:
How exactly are the strategy parameters defined in the code?

Example:
CODE:
Please log in to see this code.


QUOTE:
Are PVs enabled?

Not sure what this refers to. If you mean the red "PV" toggle to use / not use Preferred Strategy Parameter Values, the answer is no, since there are no PVs yet in this case. I just ran the optimization and had not yet set any PVs. I just want to backtest with a particular set of parameters that came out of the optimization before committing to any PVs. My workaround has been to go ahead and set the selected row as PVs and then run the backtest with the PVs, but again sometimes I have seen backtests work with the double-clicked row without setting them as PVs.

QUOTE:
Maybe you did click "Save Parameters"? More details required.

I did not click "Save Parameters" or perform any other action, other than double-clicking a row in the Optimization results.

Thanks
profile picture

Eugene

#6
Let me clarify what I was asking with regard to defining the StrategyParameters. Please paste the complete constructor w/o omissions or edits:

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

ronc

#7
Here is the constructor:

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

ronc

#8
Update: Just observed something interesting. I closed the strategy, restarted WLab, loaded the strategy, reran the optimization, and this time it worked - the backtest used the double-clicked parameter row. Previously the strategy file was not in an unsaved state (there was no asterisk next to the strategy name in the title bar of the window) so not clear why closing/reopening the file would make a difference.
profile picture

Eugene

#9
Re: constructor. At least there are no duplicate parameter labels which is good (they must be unique, or problems will happen). But why does the code have four Straps with 0.0001 step? This is illogical and strange. Maybe it has something to do with this strange problem that no one else seems to have noticed.
profile picture

ronc

#10
The 0.0001 values are there to insure that the steps in those variables are small enough so that any variations are smooth, i.e. no significant discrete steps. Probably 0.001 is OK, but 0.01 starts to "discretize" some variables, and I am not sure on which WL optimizers use or ignore these increments (I think genetic ignores the steps?) so I generally use 0.0001 to always avoid all discretization, either when adjusting params manually or when using an optimizer. I do not use exhaustive optimization. Usually genetic and sometimes Monte Carlo.
profile picture

ronc

#11
I have eliminated the 0.0001 values; changed them to 0.01. No effect.When I double -click the parameters row, i can that Strategy Parameters window in the lower left flashes briefly, and the values that are left in the window are the default parameter values from the code, as opposed to the values in the optimization results row that I double clicked. Also the words "Strategy Parameters" in the lower left are in red. I can get the parameters to be used if I right click and save them as PVs.
profile picture

Eugene

#12
My guess is that you could've overridden the parameters by using "Save Parameters" before (FAQ: Why am I unable to "Reset" and "Save parameters"). At any rate, copy the Strategy code into a new Strategy window to start anew, save, and retry.

QUOTE:
Also the words "Strategy Parameters" in the lower left are in red.

This simply indicates that the parameters have been changed i.e. are not their default values.
profile picture

akuzn

#13
QUOTE:

CreateParameter("stopLossLimit", 0.5, 0.0, 0.15, 0.01);

Sorry but quick look and it seems default value is out of range of min/max
profile picture

Eugene

#14
Thanks Aleksey, you hit the nail on the head. An obvious coding error that somehow got overlooked.
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).