Optimization Strategy Parameters Observation
Author: Ben_Zurich
Creation Date: 11/21/2011 7:58 AM
profile picture

Ben_Zurich

#1
After running an optimization, I can select one of the results, right-click and choose "Set these parameter values as default for the strategy". Then I see the values populated correctly in my strategy code. So far so good. Now when I press "Go", I would expect that the program takes these default parameters and runs the strategy.

BUT THIS IS APPARENTLY NOT THE CASE! It takes the values from the Strategy Parameters Window on the lower left of the WL6 window, stemming from an earlier run which in most cases has nothing to do with the current optimization.

How can I bring the new default parameter values to this little Strategy Parameters Window without having to adjust each individual parameter?
profile picture

Eugene

#2
Good or bad, but this is the design we all have to live with and it's documented in the User Guide: Reference > Data Panel > Strategy Parameters. Once you "Save" that becomes the default. (Also, parameter slider values could be saved with the strategy if the "Strategy-Dependent Preferences" option in Wealth-Lab's Preferences > Advanced Options was active.)

BUT DON'T PANIC YET! ;) Change any parameter to bring the bluish "Reset" label back to life, click "Reset", and hit "Save Parameters". This will reset the default strategy parameter set to the new one saved in its constructor when you chose "Set these parameter values as default for the strategy".

profile picture

Ben_Zurich

#3
Thank you for your answer. However I was not able to reproduce what you say.

Upon clicking into the little Strategy Parameters window in order to revive "Reset" and hitting on that icon, the icon "Save Parameters" is grayed out. Everything I try as an attempt to "synchronize" 'code' and 'little window' doesn't work for me.

Am I missing something?
profile picture

Eugene

#4
You need to change any parameter to make the "Reset" label active.
profile picture

Ben_Zurich

#5
Yes I know that. I said: after hitting Reset the 'Save Parameters' icon is grayed out.

Anyway as the sliders apparently take precedence over the script default parameters, there must be a simple way to bring the parameters from an optimization result to the sliders, right?
profile picture

Eugene

#6
If you clicked "Set these parameter values as default for the strategy" before even once, they have become the new selected parameters. If you want to change them after chosing "Set these parameter..." again, you do the following:

1. "Set these parameter..."
2. "Run the Strategy" or "Compile + Go" to recompile (because the code has changed!)
3. Click "Save". (or Change any parameter, click "Reset", then Save.)

Clicking "Go" is not enough in your case because the code has to be recompiled after Optimizer modifies the constructor by inserting new default Strategy parameter values.
profile picture

Ben_Zurich

#7
This is not what I am experiencing.

After performing 1. and 2., the little "Strategy Parameters Window" did not change a bit in order to reflect the new values, and "Save Parameters" and "Reset" are grayed out, and inspecting the parameter values with PrintDebug still show the same old values, despite of the fact that the code contains the new values from the optimization.
profile picture

Eugene

#8
Step by step, what you are doing?
profile picture

Ben_Zurich

#9
Starting WL6
Opening a strategy
Change parameters with the sliders while watching the equity curve
Say that two parameters now have the values 4 and 6 (sliders, not code)
Go to the Optimization: Optimize the strategy (Monte Carlo method)
The best values that come out, say, are 2 and 8
Right click on the result which have parameters 2 and 8
click on: "Set these parameter values as default for the strategy"
Look at the editor code: Yes, the default parameters have been inserted (unfortunately, this has no effect at all)
Compile and run the strategy, and PrintDebug the two parameters
Guess what values are printed out in the Debug Window? 2 and 8? NO. Still 4 and 6.

If I want to see the outcome with the new parameters 2 and 8, I have to manually adjust the two parameters with the sliders. Often even this will not be possible as the Monte Carlo method disregards the step parameter. So I have to manually adjust the step parameter in my code, compile it, and then can adjust the sliders to the desired value. This is very time consuming.

I have found out that:

in the case of the default parameter, the value in the sliders take precedence
in the case of the min, max, step parameters, the values in the code take precedence (after compile has been pressed)

I just can't follow this reasoning behind this.
profile picture

Eugene

#10
For me the question boils down to this one:

Why does Execute (or Compile/Go) not adhere to the new Default parameters, requiring user to drag parameter sliders (in order to be able to Reset to new defaults) and preserving last known Strap set?

I leave the verdict up to the expert (Cone).
profile picture

Cone

#11
The default values for StrategyParameters in the code are only the default values initially. When you click "Save Parameters", those are the values that are saved as the new default, but this action will not change your code (as the Optimizer does).

Anyway, since there is a lack of mention of it in this post, maybe using "Preferred Values" (PVs) will give you what you want. Run your optimization, apply the new values to all symbols in the DataSet, and then make sure to click the PV button on the Strategy Window or Strategy Monitor.
profile picture

Ben_Zurich

#12
Yes, that's the right answer. Thank you very much!

Bottom line (for single symbol) :

1. optimize
2. choose row to examine
3. right click this row and press "Set these parameter values as default for the strategy"
(ensuring that the default parameters, min/max/step are reflected in the code)
4. right click this row and press "Assign Preferred Values to the selected symbol to this row"
(ensuring that the new parameters have any effect on the strategy run)
5. Press "Go" and examine the chart for this parameter set
6. Now the PV button toggles between the "Saved Parameters" and the "Preferred Parameters"

In my opinion, the fact that any change of the Strategy Parameters (sliders) affect the outcome but are not reflected in the code is VERY MISLEADING. The same applies to parameter changes to the code which do NOT have any effect on the outcome.

I wonder what the behaviour is when using Visual Studio C#???
profile picture

Cone

#13
If you're asking how does PVs work with compiled strategies, they don't. It's a long-standing bug. The strategy default values and PVs were designed to be saved in the strategy's XML file, which doesn't exist for compiled strategies. If this bug makes it to the top of the deck some day, I imagine that the solution will be to create an XML helper file for compiled strategies to provide that data store.
profile picture

Eugene

#14
Bug #3844, Preferred Values cannot be saved for Strategy Libraries
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).