Using Money Management Rules With Multiple Positions
Author: snout_hound
Creation Date: 1/7/2009 12:04 PM
profile picture

snout_hound

#1
I am new to Wealth Lab and am wondering if there are any good examples to look at as I attempt to write a Wealth Lab script to simulate and back test an approach to trading that I am considering. My first attempt along this line is related to techniques and strategies I have been learning about while reading some books on trading by Dr. Alexander Elder. One question relates to the money management aspect of the simulation or back test. I would like to limit the risk on a single trade to some percentage of my trading account as determined at the first of each month where risk is computed from the difference in the entry position and a stop and multiplied by the number of shares. I would also like to limit the max loss in a month to some percentage. If I hit that max loss for a month then I stop trading until the beginning of the next month. Since the value of the stop can move if the trade moves in a favorable direction, the conditions for determining if another trade can be entered would be changing as the simulation
steps forward in time. Also, the values for max loss on a single trade and max loss for a month would be changing from month to month. And, I would also most likely have more than one trade open at a time. This sort of money management approach with multiple open positions does not seem possible with the Portfolio Simulation feature of Wealth Lab. So, I'm assuming that it would be necessary to program all of this within a Wealth Lab execution script. Has anyone written a Wealth Lab script that does anything like this with money management that I would be able to use as an example to start with? I assume it is possible to do what I am describing with Wealth Lab.

Thanks for any help in advance,

Dave
profile picture

Cone

#2
Aleksey and Eugene have something up their sleeves that makes testing this type of strategy possible in Version 5. Eugene said he'll prepare a KB article with an example for the Wiki site in a few days.
profile picture

snout_hound

#3
Thanks. I'm a bit confused with the reply. Does this mean that it is currently not possible to do what I described with Wealth Lab? If so, does this mean that I will have to use a new version that is not yet released?

Thanks,

Dave
profile picture

Cone

#4
For Version 4, an example is already posted here: Interacting Dynamically with Portfolio Level Equity

For Version 5, there's a clever solution that makes it possible and it will take a KB article to explain it.
profile picture

Eugene

#5
Oh and by the way, a simple version of Elder Money Management script was already in Code Library for Version 4.
profile picture

snout_hound

#6
Thanks. I will look forward to the KB article. I'll also take a look at the two postings mentioned above.

Thanks again,

Dave
profile picture

snout_hound

#7
I thought of a couple of additional questions. First, will there be a post to this thread when the KB article is available? Second, is it possible with this new solution to have multiple positions on the same or different stocks at the same time? I mentioned that in my original post but don't think that issue was addressed.

Thanks,

Dave
profile picture

Cone

#8
1. Sure.
2. You can have any combination of position that you program for - I guess we take this for granted.
profile picture

Eugene

#9
QUOTE:
First, will there be a post to this thread when the KB article is available?

Don't worry. Writing code and the KB article will take more time than expected: first, I will finish and release an update to Community.Visualizers that contains Analysis Series view (that's one of the missing WL4 tools.)
profile picture

snout_hound

#10
Thanks. I'll keep checking this thread.

Dave
profile picture

Eugene

#11
Dave

We haven't forgot your request.

But developing the "equity curve interaction" script for WL5 was fun so far, and took longer than expected. For those who are interested - surprisingly, the WL5 way of doing things has absolutely nothing in common with WL4's (link above). Not a single line.
profile picture

snout_hound

#12
Thanks. I will keep looking. Meanwhile I am studying the WL5 documentation and trying to do simpler things with it.

Thanks again and look forward to the update.

Dave
profile picture

DartboardTrader

#13
It's time for a wish.. let me run a strategy against a strategy's outcome.

This would allow one to perform some portfolio equity management, for instance, by buying and selling a "data set" of strategy results.

One example might be a "buy more if position down by x%".

Or given a group of strategies and symbols, buy into the strategy that satisfies some programmed criteria (e.g. the strategy is 2% APY ahead of the others in the group.)

Like I said, a wish.

--Mike
profile picture

Eugene

#14
Dave

This is just to let know those whom it may concern: I hit an obstacle when implementing the dynamic equity interaction script for WLD5. We can have Wealth-Lab nicely interact with the equity produced by a market order-only trading system. However, there is a showstopper when stop and limit orders come to play. Now waiting for the developer's verdict to tell what's wrong here.

profile picture

wycan

#15
Eugene,

Is there a way just to retrieve the current Equity or Drawdown within a script ?
profile picture

Eugene

#16
Yes it is. Shortly we'll release an update to Community.Components with the necessary set of supporting functions plus a KB article to illustrate their usage.
profile picture

wycan

#17
Excellent. Thx Eugene.
profile picture

Eugene

#18
Update: the KB article has just been released. Unfortunately there are certain problems so it's nothing but "beta" at this point. More details HERE.
profile picture

wycan

#19
Eugene,

does this work for a portfolio of stocks ? I tried it but it seems like it charts the equity curve for the stock you click on.

What I would like to do, is run the simulation on a dataset (basket of stocks) and put a moving average on the equity curve. As the equity curve rises above the moving average it would suggest conditions are better, falling below - conditions poorer etc. Anyway to accomplish that ? I'm not opposed to writing any of this data out into ascii files and importing into a dataseries as a separate stock.. but not sure how to write out the open positions etc. any help would be appreciated. thx
profile picture

Eugene

#20
QUOTE:
does this work for a portfolio of stocks ?

Yes, definitely - it works on a portfolio of securities. (There's a single symbol mode overload as well, but since this is an undocumented stuff I won't go into details.)

QUOTE:
I tried it but it seems like it charts the equity curve for the stock you click on.

It shouldn't, but there was synchronization missing in my code (that's why it's a "beta") that made it change from symbol to symbol on some DataSets. Thanks for the heads-up, I've updated the KB article code.

Put this line immediately below the "DataSeries globalEquity..." definition:
CODE:
Please log in to see this code.


QUOTE:
What I would like to do, is run the simulation on a dataset (basket of stocks) and put a moving average on the equity curve.

There's a DataSeries called "globalEquity" in the example code #3 - put a moving average on that series.
profile picture

snout_hound

#21
Hi Eugene,

I've been on travel for awhile and so have not had time to respond. Thanks for your work and I will take a look at the KB article.

Dave
profile picture

Eugene

#22
Hi Dave

Please keep in mind that 1) it's a beta version and 2) we still need to hear from the developers on internal tick adjustment.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).