Hi,
I just adapted my possizer to be able to exclude trades running extreme good (eg >40%).
When WL do sizing, the normal way is to do probing with 1 share. So I could take the NetProfitPercent to eleminate the trades.
Everything is working fine when you run the strategy with "Run Strategy" or "Backtest on all Symbols".
But: when you modify a parameter in the Possizers, WL starts a new run (expected). But this run is not done with the probing of 1 share per position but it's showing the sizings from the prev. run in the currentpos object.
Is this by design? I think in Prior Versions the sizing is always done with 1 share. Is there a method to clear the old values before doing the new run?
greetings
Erich
Size:
Color:
Erich,
This should not happen and I think it's because of the way your PosSizer is coded. Seems like you're making the same mistake as in a previous conversation:
Clearing the cache"Run Strategy" resets the class-level variable in your PosSizer, but modifying a PosSizer parameter (or clicking "Go") does not. As I'm used to say,
do NOT define variables at class level unless you really want to do it. ;)
Size:
Color:
Eugene,
I double checked the code - there are no class Level parameters involved.
WL is calling the SizePosition function of the possizer. one of the paramters is "currentPos".
In the currentPos Parameter WL sends the psoition which needs to be sized to the possizer. So: The value of this Parameter is coming from WL and has nothing to do with any of my variables in the possizer.
Fact is: in currentpos the size is 1 only for the first run. When changing the values of the sizer via UI the in the next run the size is given from the Prior run.
So: Why is WL sending a position in the "currentPos" parameter to the sizer having an other value than 1 in size?
Size:
Color:
I think I finally understood your question. There's one unexpected event that happens after rerunning a PosSizer or after selecting a different position sizing method. And this is an extra call made by Wealth-Lab to set the position size for the right click trade menu. This extra call shouldn't be there, but leaving things as they are was believed to be a lesser evil than fixing it.
It's unexpected, and I think this is why you're confusing this
single extra run with
"values from previous runs". Of course this is untrue. Just disregard this run while debugging - it doesn't affect the position sizing for backtest/alerts, and you only have a chance to notice it under debugger.
And if this doesn't seem to apply, then my last blind guess is that your code might be reading/writing the PosSizer parameters incorrectly. Double check that you followed the
PosSizer demo code precisely. The problem is rooted in your code.
Size:
Color:
Eugene,
not really sure what you mean with the extra call and that I only see it in debugger. It's not just a single call - it's running the full strategy over the full selected portfolio.
Anyway.
Again: I do not have any problem with my parameter setting. This works pretty perfect, I can trace and verify this in debugger. The only problem is that if you change the settings of the possizer in the UI, WL starts a new run with the new settings of the same possizer over the selected portfolio (which is a correct behav.) but sends the prev. sizes in the currentPos parameter instead of size 1. I do not have any influence of what WL is sending via this parameter.
As long as you don't use any of the values depending on the size, this would not be a Problem (eg standard possizer). I don't have the source of the standard possizer, but I'm sure if you would start your debugger and trace the possizer you would be able to reproduce the behave.
Size:
Color:
It could have been less difficult to understand, despite all the verbage, if your posts mentioned the .Shares property. Finally, got it after running the debugger: the currentPos.Shares property contains values from the previous run. Since this is how Wealth-Lab operates (I checked in 6.5 and there's no difference), let me ask the developer and get back to you.
Size:
Color:
Thank's Eugene,
Merry X-Mas!
Size:
Color:
Erich,
Got an answer. Although this might not necessarily be by design, you're not expected to use the Shares value to make decisions because it's the ultimate output of the whole PosSizer processing. At least during my development (which included over 30 very different PosSizers) I haven't had any need to resort to the currentPos.Shares property.
You already know the workaround (which is to use "Run Strategy" or "Backtest on all Symbols") but still, could you clarify the point behind doing this in your PosSizer? Maybe there's an alternative way.
Size:
Color:
Eugene,
thanks for your Information.
In my Possizer I want to eleminate / ignore trades having NetProfitPercent > xx%. If you look at currentPos I could use the currentPos.NetProfitPercent. But if in the prev. run this position would size with 0 (currentPos.Shares=0) the currentPos.NetProfitPercent also holds 0.
My workaround now is to calculate the NetProfitPercent by myself ....
It just would be nice to have variables always have the same values over the testruns. In my oppinion, it does not make sense WL NOT to reinitialize them.
Greetings
Erich
Size:
Color:
Erich,
QUOTE:
But if in the prev. run this position would size with 0 (currentPos.Shares=0) the currentPos.NetProfitPercent also holds 0.
Why'd one expect the opposite if the Position was skipped? This outcome seems reasonable to me.
Size:
Color:
Eugen,
QUOTE:
Why'd one expect the opposite if the Position was skipped? This outcome seems reasonable to me.
It's correct, that the Position WAS skipped in the prev. run, but thats history. But when you change parameters and WL starts a new run, why would you expect to eleminate the same positions?
Size:
Color:
I don't follow you. WL doesn't eliminate the same positions - it skips only those trades that can't be taken during the current run.
Size:
Color:
Eugene,
you digress the main question.
My question is only: Why is in a second run of a strategy the currentPos parameter populated with an value of a prev. run instead of currentPos.Shares=1 ?
The manual says it should be initialized with size of 1 share.
QUOTE:
Executing System...
With the test data loaded in memory Wealth-Lab executes the Strategy on each symbol individually in serial fashion and in a Raw Profit mode. Trades generated by the Strategy are stored in a list with an initial size of 1 share. Since Wealth-Lab is Position-based the size of a Position is unimportant during the Strategy's execution as Position Sizing is applied later using real-world rules. Armed with a list of trades, Wealth-Lab sizes each Position and synchronizes the trades bar-by-bar as the combined equity curve is calculated in a chronological fashion.
But anyway - I found my workaround....
Size:
Color:
Hi Erich,
QUOTE:
Why is in a second run of a strategy the currentPos parameter populated with an value of a prev. run instead of currentPos.Shares=1 ?
We don't know for sure but won't be far from truth assuming that since the developers say it might not be by design, it's probably an issue (with a
very low impact).
Size:
Color: