How to add strategy parameter?
Author: leeto
Creation Date: 6/5/2015 7:53 AM
profile picture

leeto

#1
Could you help me run simple optimization. Let say I would like to optimize initial stop-loss order.
So as far as I'm understand I should take generated parameter from optimization window (which called strategyParameter1 ) and put it on the place of my code which represent manipulation with stop-loss order.

CODE:
Please log in to see this code.


However, this code is don't compile and gives me error : "Operator "-" cannot be applied to operands of type 'double' and WealthLab.StrategyParameter "

Could you tell me what should I do in order that run optimization.

Many thanks in advance !
profile picture

Panache

#2
The following code shows how to code various types of sliders.

CODE:
Please log in to see this code.


I don't believe strategy parameters can be double, so instead of using a range of 0.01 to 0.2, use 1 to 20 and divide it by 100 inside your program.
profile picture

Eugene

#3
Panache,

QUOTE:
I don't believe strategy parameters can be double, so instead of using a range of 0.01 to 0.2, use 1 to 20 and divide it by 100 inside your program.


For sure they can be double and it is documented in the WealthScript Programming Guide chapter (please see below). Division is not required.

leeto,

At the risk of being repetitive, you should really start out by reading the WealthScript Programming Guide before asking any basic questions like this. This particular question is answered there in a comprehensible tutorial under Programming Trading Strategies > Strategy Parameters.

I suggest that you reconsider starting new topics in bulk the way you've been doing last days. Instead, concentrate on carefully reviewing the manual to get a handle on the basic stuff. It will pay off in the long run if you consider to make Wealth-Lab your platform of choice.
profile picture

Panache

#4
I realize you're pissed at leeto for asking a whole bunch of newbee questions. I tried to help the guy, because getting started in Wealth-Lab isn't the easiest thing. I've SO sorry for not fully researching my answer before providing him a solution that solved his problem.
profile picture

leeto

#5
Panache,

Many thanks for your support !



Eugene,

Sorry for newbee question this is indeed relatively obvious in "WealthScript Programming Guide" 's search type "optimization" and find needed article.
profile picture

leeto

#6
Below you can find the answer on the question.

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

Eugene

#7
leeto,

You've started 15 threads this week (and this is the record) but the problem is that you don't seem to catch up. Here's what I mean. Although lately we pointed you at a serious peeking error (and a potential exception generating bug) in your code, you keep on duplicating these errors again today in post #6 here (and yesterday too). Please take time to digest the new information and study the manuals. Let yourself enough time to chew on to avoid repeating the same errors.
profile picture

leeto

#8
Yes you a right. Thx that bring my attention. Indeed this is one of the places that I do quite catch yet.

However, I think start to understand if the function talking about buying at stop this mean that this is nonsense when I put stop order at the Bars.Close[bar]. I mean at the same bar.

CODE:
Please log in to see this code.


Although it will work because it will be stop market order, more correctly will be at least

CODE:
Please log in to see this code.


Now I think a get it.

btw, I start to read programming guide. It is very comprehensive material ! thx




profile picture

Eugene

#9
QUOTE:
Although it will work because it will be stop market order, more correctly will be at least

No, this is also incorrect. You can not place an order for "bar" at any price from "[bar+1]" because it's bluntly peeking into the future. See the Wiki link I referred before and WS Programming Guide, it's explained there. Looks like you're overlooking the order of parameters, thinking that including an "Open[bar+1]" makes the order execute properly at the next bar. See the QuickRef for the parameter description.
profile picture

leeto

#10
Thanks you Eugene for your help.


So according to the QuackRef

CODE:
Please log in to see this code.

and your comments

QUOTE:
You can not place an order for "bar" at any price from "[bar+1]" because it's bluntly peeking into the future.



Now I doubt that execution
CODE:
Please log in to see this code.


will give me correct results.


However, compare to the execution
CODE:
Please log in to see this code.


Results pretty much the same but different on several percents.
profile picture

Eugene

#11
CODE:
Please log in to see this code.


This particular expression does not peek. Nonetheless, there is a problem with it and to understand it let me suggest that you re-read my answer in the other discussion regarding an exception when accessing Open[bar+1] in scripts in general.
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).