[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Strange Behaviour....



PureBytes Links

Trading Reference Links




Hi, all:
 
Today, I devised a simple money management (MM) code that is applicable for 
portfolio trading in regular mode. I am sharing this to solicit any comments or 
ideas for improvement or friendly criticism. It is based on Van Tharp's risk 
management strategies applied to a portfolio. Here is the simple code with 
explanation to follow:
 
<your buy/sell/short/cover system code here>
n1=Optimize("n1",2,1,3,0.1);n2=Optimize("n2",10,2,20,1);n=n1*n2;PosQty 
= n2
SetOption("MaxOpenPositions", posqty); PositionSize = 
-n*C/(posqty*stop);
The term "n" is the total portfolio risk or "heat", and posqty is the no. 
of positions carried in the portfolio. "n" is composed of 2 variables multiplied 
together, n1 and n2. The 'stop' term is used in an ApplyStop statement as a max 
stoploss based on points (such as stop = 1.5*ATR(10), as an example). The n1 
variable is the risk in terms of % of equity that we are willing to encounter 
PER STOCK. I suggest optimizing it from 1% to 3% in steps of 0.1. The n2 
variable is the no. of positions, which are optimized from 2 to 20 in steps 
of 1. Now, n2 appears to exist in both the numerator and the denominator, since 
the PositionSize statement could just as easily be written: 
 
PositionSize = -n1*n2*C/(n2*stop);
 
Algebraically, the n2 variables cancel, but in essence they don't. Why? 
Because AB interprets a negative term in the positionsize statement as a 
percentage of current equity. So, really, AB thinks the product n1*n2, 
which is really one term "n" in the first positionsize statement above, is a 
percentage of equity. That's why we get different performances when we run the 
optimization for each value of n1 and n2. Ok, so where is this all 
leading? Well, when you run the optimization as specified above, you get a 3-D 
graph with a nicely robust flat peak. In a short-term system I've been 
experimenting with lately, I get roughly the same profit results for any value 
of n1 between 1.6 and 2.6 and for any posqty (n2) between 6 and 20. If you pick, 
say, n1 = 1.7 (as low a risk as possible without giving up much performance) and 
n2 = 10, what this means is that we are attempting to make sure we get at 
least 5 to 7 positions in our portfolio, each one risking only 
1.7% of our equity. Why only 5 to 7 when we are specifying 10? Because 
the stop is based on volatility, and the lower the volatility, the bigger the 
positionsize will be. Consequently, you wind up not having enough capital to 
take on all 10 positions (assuming you get in at approximately the same time). 

 
The above strategy differs from the simpler one shown below:
 
n = Optimize("n",14,2,20,1);
PosQty = Optimize("posqty",6,2,20,1);
SetOption("MaxOpenPositions", posqty); PositionSize = 
-n*C/(posqty*stop);
This strategy optimizes in the same system to n = 14 and posqty = 6. This 
represents a per-stock risk of 2.3% (i.e., 14/6), which fits nicely within the 
1.6 to 2.6 found above for the optimization. However, what happens is that, with 
my experimental system, I wind up only taking on about 2 or 3 positions since 
all my capital is used up before all 6 positions are filled. 
 
Any thoughts about any of the above? Be nice. It's just experimental. 

 
Thanks, folks. 
 
Regards, 
 
Al Venosa
 
---Outgoing mail is certified Virus Free.Checked by AVG 
anti-virus system (<A 
href="">http://www.grisoft.com).Version: 6.0.576 / 
Virus Database: 365 - Release Date: 1/30/2004


Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html








Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/ 
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.