Hello,
is it possible to query the number of all open positions in the script? I mean about all the symbols in the portfolio test.
Thank you
Matthias
Size:
Color:
Hi Matthias,
It's possible but not that simple:
Any Open Position (in Other Symbols) in Portfolio ModeCould you clarify: why do you think you need to get the active position count of a portfolio in a Strategy? There may be an easier solution to your task than having to rewrite your Strategy if you share your objective.
Size:
Color:
I tried it with the "Positins Options", but....
- for example, I can enter a maximum of 4 open positions
- then sometime I have 4 open positions
- if I sell 1 position at the close (3 positions are still open) I cannot buy 1 new position at the close
That's my problem.
Size:
Color:
QUOTE:
- if I sell 1 position at the close (3 positions are still open) I cannot buy 1 new position at the close
Maybe your system doesn't have enough capital to take the 4th trade?
Size:
Color:
I' m investing 4x 25% and have margin factor 10:1, so enough Capital.
Size:
Color:
You can never be sure. How many skipped trades are there on the bottom of the Trades tab? If zero, try my link in post #2 above.
Size:
Color:
The strange thing is, if I close to the next open 1 position, then WL regularly immediately opens 1 new position at the same time. The problems close/open at the same time I have only at the closing price.
Size:
Color:
Size:
Color:
yes, the same problem now in another strategy. an acquaintance told me that problem did not exist earlier in WL 4. It's annoying and I have to complicate the codes now.
Size:
Color:
If you don't wish to complicate the code, try to avoid "investing 4x 25% and margin factor 10:1". This is a recipe for skipped trades.
Size:
Color:
how should I adjust it if I wish to have a maximum of 4 open positions?
Size:
Color:
See post #8 right above. Sorry, I don't have anything more to add to this.
Size:
Color:
Wealth-Lab processes exits for AtMarket signals and frees buying power for other signals for the same bar. The same is not true for other signal types. Nonetheless, if you have set over 2:1 margin, and you're properly limiting the Strategy to 4 trades with 25% equity sizing, I cannot think of a reason other than a large amount of commission, or a size that doesn't allow the purchase of at least 1 share, (or, ok, I guess there could be reasons) .. that you cannot purchase that 4th position when another position is exited AtClose on the same bar.
If you want to post the script here or in support, and provide your settings for sizing, DataSet symbols, etc. I could take a closer look.
Size:
Color:
Hi Cone,
here is an example Code:
CODE:
Please log in to see this code.
If you use "Position Options" with 25% "Pct of Equity" and "Max open Position"=4 (and Margin Factor 10) then you will see the problem in the trade list. If positions are closed at the closing price, no new positions are opened.
If you make the whole thing the opening price, the position management works correctly. Here is the code with the small change.
CODE:
Please log in to see this code.
However, if possible, I need an uncomplicated solution at the closing price.
Size:
Color:
QUOTE:
If you make the whole thing the opening price, the position management works correctly. Here is the code with the small change.
Maybe Cone knows a trick but having tried different ways I couldn't make both the entry and exit to align at close. An uncomplicated solution at the close price might be...
CODE:
Please log in to see this code.
...while changing your entry to bar+1:
CODE:
Please log in to see this code.
Another idea that might work is to switch the scale to Monthly while retaining AtClose for entry/exit.
Size:
Color:
Thanks for the tips. I'm afraid they won't help me. The code was a simple example to demonstrate the problem. Most of my strategies have signals at the daily closing price. These are to be implemented.
Can I take a variable from one symbol to the next? Some kind of superordinate signal counter?
Size:
Color:
QUOTE:
Can I take a variable from one symbol to the next?
I tried to come up with a DataSetSymbols-looping script
like this but my attempt didn't work as expected. Have you considered Raw Profit mode? Buying power is freed in this case.
Size:
Color:
Yes, Raw Profit mode works. But I cannot set how many positions (general, long, short, etc.) should be opened. The "Positions Options" is a perfect tool if only this one problem would not be.
Size:
Color:
The problem here must be how ActivePositions is reported to the PosSizer. That's preventing new Positions to be sized on the same bar.
I don't have a simple work-around, but it works if you run a "DataSetSymbols" loop, and execute the strategy on one symbol only - like the rotation scripts. In this case, you only buy the n (4) symbols that you select by some priority (RSI), which limits the number of "raw ActivePositions" that the engine has to deal with.
To run the script below,
you need to add a reference to: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Data.Linq.dllcheck "System.Core" in the Strategy Editor > References... button > NET References tab.
1. Use the regular % of Equity sizer, 25%, with, say, 3:1 margin.
2.
Run on one symbol (one with the longest history) only!CODE:
Please log in to see this code.
p.s. This solution may exit and enter the same symbol on the same bar. With a little extra code, we can prevent the exit in those cases.
Size:
Color:
QUOTE:
To run the script below, you need to add a reference to:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Data.Linq.dll
Nice job Robert. One note: adding the file reference isn't required. Instead, topic starter should simply check "
System.Core" in the Strategy Editor > References... button >
NET References tab.
Size:
Color:
Hmmm, something is wrong with the sort... seems to always return the same result... stand by.
Size:
Color:
Code above in post #19 corrected. After a test, I had accidentally left a [Bars.Count - 1] where [bar] should have been ;)
Size:
Color:
Here's the version that doesn't unnecessarily exit a Position.
Comments in Post #19 still apply.
CODE:
Please log in to see this code.
Size:
Color:
thank you very much Cone. I'll try the codes. This is the "more complicated" variant. As I said before, this was just a simple example code. The signals from my trading systems are more complex. It'll take me a while to reprogram the logics. It won't be easy.
Size:
Color: