I am using the "X Winning/Losing Trades Within Y Trading Days" from PowerPack, and if I try to make the "Of Size" field optimizable, it isn't used in the coded version:

This is what the resulting code looks like, notice that "p.ProfitPercent < 0" is not using the optimization parameter:
This is what the resulting code looks like, notice that "p.ProfitPercent < 0" is not using the optimization parameter:
CODE:
cntPos = GetPositions(false).Where(p => !p.IsOpen & p.ExitDate >= cutoff & p.ProfitPercent < 0).ToList().Count;
Rename
QUOTE:
I try to make the "Of Size" field optimizable
I'm not sure what they mean by "size". Size of profit?
I'm guessing "size of profit" because p.ProfitPercent is showing up in the C# code. But if that's the case, why would you want to set your profit size to a specific number to optimize around in the first place?
The intended use case here is to avoid trading symbols that have recently resulted in a large loss, say -5% or worse.
Note that everything works correctly here if you manually enter a value into the "Of Size" field. It's only when you try and make that field optimizable that the bug occurs.
I did some more testing and found that the bug specifically occurs when you have "Of Size" set to 0.00 as the default value. Something about this prevents it from being turned into an optimization parameter.
Note that everything works correctly here if you manually enter a value into the "Of Size" field. It's only when you try and make that field optimizable that the bug occurs.
I did some more testing and found that the bug specifically occurs when you have "Of Size" set to 0.00 as the default value. Something about this prevents it from being turned into an optimization parameter.
QUOTE:
The intended use case here is to avoid trading symbols that have recently resulted in a large loss, say -5% or worse.
Thanks for that clarification.
Looking at the C# code in the original post, it is simply returning the count of the completed trades where p.ProfitPercent < 0. But that's not going to give you the recent profitability rate.
What I do is compute the "WMA" of the last 5 positions relative to profit, and return that figure as part of the Signal message. That let's me know from the Strategy Monitor Signal pane which stock signals are worth moving over to my Quotes window watch list.
I put WMA in quotes because taking the last 5 position %profits is not a "moving" average. It's a simple weighted average over time in this case.
It looks like this is how Eugene intentionally coded this Block. It seems the idea is that if the parameter value is set at zero it implies that you do not want to consider the size of the position, so optimization is ignored.
Not really. F1 Help explains this item with an example. "Size" (which isn't the best term - could be changed to "Value") is the Dollar or Percent cutoff value that counts as a profit.
It looks like the problem is this - if you don't modify the "Size" and leave as 0, then it will always use 0 and the parameter won't be optimized. Basically, 0 is just disabling the optimization. It still uses 0 as the cutoff, so it beats me why it's programmed to disable the optimizable parameter.
For now, make the size non-zero (even 0.001) and it will work.
CODE:
AddParameter("Of Size", ParameterType.Double, 0, 1, 5, 1);
For now, make the size non-zero (even 0.001) and it will work.
Your Response
Post
Edit Post
Login is required