edwkelly8
 ( 0.09% )
- ago
This simple code in WL6
Constuctor
CODE:
GetRetrace = CreateParameter("GetRetrace", 0.00, 0.00, 5.00, 0.020); //name, value, start, stop, step SetRetrace = CreateParameter("SetRetrace", 0.00, 0.00, 5.00, 0.020); //name, value, start, stop, step


protected override void Execute()
CODE:
double retrace = 0; Waves = new Waves(this); if (SetRetrace.Value == 0) { retrace = Waves.GetRetrace(); GetRetrace.Value = retrace; } else { retrace = SetRetrace.Value; }

Produces correctly


But in WL8
Constructor
CODE:
_GetRetrace = AddParameter("GetRetrace", ParameterType.Double, 0.00, 0.00, 5.00, 0.020); _SetRetrace = AddParameter("SetRetrace", ParameterType.Double, 0.00, 0.00, 5.00, 0.020);


public override void Initialize(BarHistory bars)
CODE:
double retrace; _Waves = new Waves(this); if (_SetRetrace.AsDouble == 0) { retrace = _Waves.GetRetrace(); _GetRetrace.Value = retrace; } else { retrace = _SetRetrace.AsDouble; }


Produces nothing


Please advise.
0
769
Solved
16 Replies

Reply

Bookmark

Sort
Glitch8
 ( 9.28% )
- ago
#1
That’s not nothing. It’s two parameters with default values of zero just like you coded 🤷🏼‍♂️
0
edwkelly8
 ( 0.09% )
- ago
#2
Are you saying i can only set defaults the constructor? The double retrace has 1.25 so why doesn't this GetRetrace.Value = retrace; work??
0
edwkelly8
 ( 0.09% )
- ago
#3
Maybe I'm just not being clear.
0
edwkelly8
 ( 0.09% )
- ago
#4
Could you send a link showing how to set Parameter values in WL8?
0
Cone8
 ( 5.88% )
- ago
#5
CreateParameter("GetRetrace", 0.00, 0.00, 5.00, 0.020); //name, default value, start, stop, step

You can do it there, OR, you can use the slider and click the button -
0
- ago
#6
QUOTE:
Could you send a link showing how to set Parameter values in WL8?

Here's that link, which duplicates the QuickRef:
https://www.wealth-lab.com/Support/ApiReference/UserStrategyBase

QUOTE:
Call this from within the Strategy's constructor to add a parameter to the Strategy.
0
edwkelly8
 ( 0.09% )
- ago
#7
I'm still not seeing anything that will allow me to set a parameter value from code as it was in WL6. If that's the case, and they can only be set from the UI, then so be it.
0
Glitch8
 ( 9.28% )
- ago
#8
Pass a non zero default value in the parameter, what’s so difficult about this??
0
Glitch8
 ( 9.28% )
- ago
#9
Here’s how to do it:

CODE:
_GetRetrace = AddParameter("GetRetrace", ParameterType.Double, 1.25, 0.00, 5.00, 0.020);
0
edwkelly8
 ( 0.09% )
- ago
#10
I wish i knew. All I wanted was to replicate the code above in WL6 to WL8. Sorry for the confustion
1
Cone8
 ( 5.88% )
- ago
#11
It's the same in WL6! The only difference is specifying the ParameterType.
0
edwkelly8
 ( 0.09% )
- ago
#12
Its not the same, at least not for me. I use these parameter text boxes to show variable changes so I write to them from code all the time. I'm just not able to get the parameter text boxes to show anything in WL8..

I took the same two simple lines of code here to use in both, as above, for WL6 the constructor is
GetRetrace = CreateParameter("GetRetrace", 0.00, 0.00, 5.00, 0.020);
and in Execute
GetRetrace.Value = 23;
return;
gives


WL8 constructor is
_GetRetrace = AddParameter("GetRetrace", ParameterType.Double, 0.0, 0.0, 5.00, 0.020);
and in Initialize
_GetRetrace.Value = 23;
return;
gives
0
- ago
#13
Once again, it's set in the Strategy's constructor. See Glitch's reply #9.
0
Best Answer
Glitch8
 ( 9.28% )
- ago
#14
Changing it in Initialize will not work in WL8. Initialize is not even called until the Strategy is executed (Run Backtest.)

Like we've been saying, you need to change the default parameter in the constructor, like this:

0
edwkelly8
 ( 0.09% )
- ago
#15
As I was trying to say earlier, I write to these values throughout the run so at construction I have no idea what these values will be.
0
Cone8
 ( 5.88% )
- ago
#16
Parameters are used for sliders and optimizations. They have to be defined a priori.

Your strategy can invent any other set of variables to use at runtime, but you can't use them as sliders or in optimizations. Just forget about Parameters for this purpose.
1

Reply

Bookmark

Sort