I want to use my strategy, which takes some short term trades to preserve some of the positions to build a core holding. I want the strategy to continually build a long term core position, by keeping some of the shares that I would normally trade. For example, every time I close out a trade I keep 2% and add it to my core long term position that I would never sell. At the end of the test period I would expect to have a sizable long term core position that would have taken advantage of long term growth, dividends, and would have been treated more favorably from a tax perspective.
I looked at the SplitPosition() method, but am getting some strange results. I noted that you can get unpredictable results when back testing. Is there a better way to do this - perhaps a position sizer?
Thanks for any help.
Size:
Color:
PosSizers are only used to size positions, not to establish or exit them.
Let's take a look at your code to understand what it does in order to get those unpredictable results, and then find out how do you think Wealth-Lab should work in some particular scenario (code, symbol(s), time frame, data range etc.)
Size:
Color:
Eugene,
Actually I think that I just had a coding error. I had coded the split at the top of the trading loop, so it kept on reducing the size. Now I coded it so that the split only occurs before I take action on a trade. To visualize it better, I used a fixed amount of shares (100) to ensure that it was working.
Here is a sample of a working model:
CODE:
Please log in to see this code.
Size:
Color:
I don't see a good way of knowing how many shares that you are still holding at the end of a back test. It would be cool if there was something on the backtest report that showed something like:
Current Holdings: 1000 shares
Average Cost Basis: $50
Current Shares subject to short term capital gains: 100
Current Shares subject to Long term capital gains: 900
Current Dividend from open positions: 5%
etc, etc.
It would be cool to add those shares to a bucket called "Core Holdings"
Thanks for the help!
Size:
Color:
QUOTE:
Here is a sample of a working model:
Hmm. This is a standard single-position strategy template but you're now holding two positions. Multi-position scripts require a different approach, like the WealthScript Programming Guide illustrates, for example (
Programming Trading Strategies > Multi-Position Strategies > MP Strategy Template)
Re: Average Cost Basis - that's easy to code yourself.
CODE:
Please log in to see this code.
Size:
Color:
Hi Eugene,
You are correct about the MP template, although the template doesn't exactly match this use case. The template loops through the positions list for each bar. In this case I know that I only need to deal with the current trading positions and leave the core positions alone.
I also need to keep track of when it is OK to trade, because the system tries to buy for each signal. My pattern is Buy, sell all except 10%, buy, sell all except 10%, etc. This requires me to code some logic to keep track of when my trading position has been sold. Otherwise the following can happen. Buy 100, Buy 100, sell all except 10%.
I will work with it and let you know...
Size:
Color: