How to print strategy parameters in trade descriptions?
Author: kbellare
Creation Date: 7/21/2013 12:12 PM
profile picture

kbellare

#1
How do i print strategy parameter values and other variables in trade descriptions, so i can see them in the Trade Results tab?

e.g.
ShortAtStop(bar,Close[bar],"Short <strategy parameter>")

thanks
Kiran
profile picture

Eugene

#2
First of all, it's impossible to ShortAtStop(bar) at Close[bar] - this is a blunt peeking into the future.

There are numerous ways to skin this cat. As one could learn from the WealthScript Programming Guide, Programming Trading Strategies > Strategy Parameters, to refer to a Strap value, call .ValueInt or .Value. The rest is entirely up to you:

CODE:
Please log in to see this code.


CODE:
Please log in to see this code.


CODE:
Please log in to see this code.


You get the picture.
profile picture

aykuts

#3
Hi,

Assume that I have 4 Strategy Parameters, and I would like to print the `preferred values` of this strategy parameters set, using a sort of a loop.

I cant recall where, but I found this piece of code that supposedly captures the values of the strategy parameter window for the given strategy:

CODE:
Please log in to see this code.


However, this code prints not the preferred values of the strategy parameters, but rather, the default values of each strategy parameter.

i.e. if the default values of 2 strategy parameters are, say (1,2) and the preferred values are, say, (11,12),
- this loop prints `(1,2)`
- but, what I am after is the preferred values of the strategy parameters, i.e. `(11,12)`
- as when I printDebug(strategyParameter1.ValueInt), it returns, correctly, `11`.


**

How should I modify the code piece presented above so that I can, say at the end of the strategy code, capture (not the default values but) the preferred values of the strategy's strategyparameters, so that I can use this string at whereever I want? (Such as printing this string onto the ChartPanes, or, inserting into the database, or, as signalname etc?)


Thanks in advance for your interest and time.

Best regards,

Aykut


profile picture

Eugene

#4
Hi,

QUOTE:
However, this code prints not the preferred values of the strategy parameters, but rather, the default values of each strategy parameter.

Exactly, because the undocumented properties you're accessing do not deal with preferred values - they are used to store/load Straps.

QUOTE:
capture (not the default values but) the preferred values of the strategy's strategyparameters,

I haven't tested it (and obviously this is unsupported), but let me recommend this:

StrategyManager > Strategies property (collection of all installed Strategies) > Strategy object > PreferredValues property.

P.S. After pressing the PV button, the preferred values are turned on and you can access them simply by querying the ValueInt/Value property. But this is too obvious. ;)
profile picture

aykuts

#5
Thanks Eugene. I will have a look at this.

profile picture

aykuts

#6
I finalized this piece of code that captures both the names and the preferred values of the strategy parameters of a given strategy.

I hope this script helps other users.

Best;
CODE:
Please log in to see this code.
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).