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

Re: [amibroker] Re: PositionSize Variable - Help - Inexplicable Results



PureBytes Links

Trading Reference Links


Herman,
 
Tharp's code is included in the help files for 
positionsize.
 
I don't use position size based on ATR since I just do 
futures.
The amount of money varies widely among different commodities 
for the same ATR value, so I have used simple bone-head percentages to 
determine how much to place  on trades. I end up with <FONT 
size=2>PositionSize = NumCon * MarginDeposit; if I want to 
buy multiple contracts. The value NumCon is the number of contracts tobuy 
(or short) and can be controlled via equity, volatility, or whatever but usually 
a simple percentage in my case. It will be useful when TJ allows for 
multiple tiered buys (pyramiding).
 
While pyramiding usually leads to early equity 
death, there are techniques (not in AB yet) of buying contracts in groups 
of say, 5 and then selling them separately when desired criteria are met. Or 
buying 3 contracts at once, then adding contracts according to a schedule which 
tracks the cumulative "center of mass" of the contracts so a small downturn 
won't wipe out previous gains, the usual problem of pyramiding. This just means 
that after the first 3 buys, the remaining buy signals are passed through a 
filter which looks at the placement of the previous buys and makes sure 
that you're not adding positions that would make you "top 
heavy".
 
I have read with interest of those who fret about 
money management and stops that reduce their %profit from idealized amounts. 
They are usually right. Profits usually are decreased somewhat. And their 
trading longevity may be decreased without them too. I don't see money 
management as a way to raise profits, but as a way to ensure profits in a long 
term sense. A type of insurance policy for my trading.
 
I have to pay car insurance and it decreases my 
capitol, but if I get into a serious wreck I will use it then continue on. Those 
without insurance save short term money but are financially wiped out aftera 
serious wreck and lawsuits. The short term money they once saved is now gone 
too. If my trading goes into a skid, aggressive money management and stops will 
give me time to correct and continue.
Since I will probably live longer that Iexpected 
to, long term viability is my target.
 
-CS
<BLOCKQUOTE 
>
----- Original Message ----- 
<DIV 
>From: 
Herman vanden 
Bergen 
To: <A title=amibroker@xxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Wednesday, October 23, 2002 7:06 
AM
Subject: RE: [amibroker] Re: PositionSize 
Variable - Help - Inexplicable Results

<SPAN 
class=260160414-23102002>Thank you CS,
<SPAN 
class=260160414-23102002> 
I 
enjoyed the code included on Tharp's ATR-based position sizing technique.Will 
try it in the next few minutes.
<SPAN 
class=260160414-23102002> 
Can 
you tell me how applying this rule effected the performance of your trading 
system? What happened to DDs?
<SPAN 
class=260160414-23102002> 
Many 
thanks,
<SPAN 
class=260160414-23102002>Herman.
<BLOCKQUOTE 
>
<FONT face=Tahoma 
size=2>-----Original Message-----From: CS 
[mailto:csaxe@xxxx]Sent: 22 October, 2002 9:17 
PMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: 
[amibroker] Re: PositionSize Variable - Help - Inexplicable 
Results
While I'm no expert, and my most of understanding 
comes from R(eading)TFM, the line PositionSize = 30000 
means that you are investing 30000 on each and every trade, no 
matter how big your equity grows. Obviously, if your previous trades wiped 
out your equity, you're not going to be investing in any more 
trades.
 
The line PositionSize = -100 means that 
you are investing %100 of your equity on each trade. If your previous trades 
were winners, that money has been ADDED to your equity. Now for the current 
trade, you are now investing more money than the past trades. Think of it 
as rolling over your starting equity plus all your past winners and 
minus your losers. 
 
If you had gone to HELP>SEARCH and typed in 
POSITIONSIZE like I did, you would have seen:

Position sizing
This is a new feature in version 3.9. Position 
sizing in backtester is implemented by means of new reserved variable 

<FONT  
color=#ffffff>PositionSize = <size array>
Now you can control dollar amount or percentage of 
portfolio that is invested into the trade
positive number define (dollar) amount that is 
invested into the trade for example:<FONT 
color=#ff0000>PositionSize 
= 1000; // invest $1000 in every trade
negative numbers -100..-1 define 
percentage: -100 gives 100% of current portfolio size, -33 gives 
33% of available equity for example:<FONT 
>PositionSize = -50; /* always 
invest only half of the current equity */ 
dynamic sizing example:<FONT 
 color=#ffffff>PositionSize = - 
100 + RSI();as RSI varies from 0..100 this will result in position 
depending on RSI values -> low values of RSI will result in higher 
percentage invested 
If less than 100% of available cash is invested then 
the remaining amount earns interest rate as defined in the 
settings.
There is also a new checkbox in the AA settings 
window: "Allow position size shrinking" - this controls how backtester 
handles the situation when requested position size (via <FONT 
 color=#ffffff>PositionSize 
variable) exceeds available cash: when this flag is checked the position is 
entered with size shinked to available cash if it is unchecked the position 
is not entered.
To see actual position sizes please use a newreport 
mode in AA settings window: "Trade list with prices and pos. size" 

For the end, here is an example of Tharp's ATR-based 
position sizing technique coded in AFL:
Buy = <your buy formula 
here>Sell = 0; // selling only by 
stop
TrailStopAmount = 2 * ATR( 20 );Capital = 
100000; /* IMPORTANT: Set it also in the Settings: Initial Equity 
*/
Risk = 
0.01*Capital;<FONT 
 color=#ffffff>PositionSize= 
(Risk/TrailStopAmount)*BuyPrice;ApplyStop( 2, 2, 
TrailStopAmount, 1 );
The technique could be summarized as 
follows:
The total equity per symbol is $100,000, we set the 
risk level at 1% of total equity. Risk level is defined as follows: if a 
trailing stop on a $50 stock is at, say, $45 (the value of two ATR's against 
the position), the $5 loss is divided into the $1000 risk to give 200 shares 
to buy. So, the loss risk is $1000 but the allocation risk is 200 shares x 
$50/share or $10,000. So, we areallocating 10% of the equity to the 
purchase but only risking $1000. (Edited excerpt from the AmiBroker 
mailing list)
C'mon Nick. You can do it. HELP>SEARCH is faster than 
email and usually more detailed.
Be a future AB guru.
-CS
 
<BLOCKQUOTE 
>
----- Original Message ----- 
<DIV 
>From: 
n94612 
To: <A 
title=amibroker@xxxxxxxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 

Sent: Tuesday, October 22, 2002 3:40 
PM
Subject: [amibroker] Re: PositionSize 
Variable - Help - Inexplicable Results
Thanks to all who responded with such very helpful 
input: Ara, Ken, Herman, Rick, Mark, and Tomasz.I had 
overlooked the fact that in AmiBroker, PositionSize is expressed in 
dollars, not shares.  This was my oversight due to the fact 
that in most of my other readings (Tharp, Turtle Trader site, and 
perhaps a dozen or so other sites, Position Size IS expressed in 
Number of Shares, and is defined as "the number of Contracts or Shares 
purchased."This realization has resulted in me having to rewrite 
parts of many systems and explorations, but it's so good to have it 
cleared up in my own mind and see where the error arose.My 
apologies for not doing enough due diligence research especially in 
AmiBroker's Help before posting, and thanks once more for everyone's 
helpfulness and patience through this small bump in my learning 
curve.Just one last question on this subject:  Shouldn'tthe 
following two situations produce identical results?1) 
PositionSize = 30000; ( with equity set to 30000 in Settings as well 
as in "Capital" variable in code and no position size shrinking)2) 
PositionSize = -100   ( with equity set to 30000 in Settings as 
well as in "Capital" variable in code and no position size 
shrinking)Even after I adjusted my code to fix the 
misunderstanding I had  regarding position size, these two tests, 
which seem to me should be equivalent, produce entirely different 
results.Here are the different results obtained in each 
case:      # of 
Tr            
Avg.Tr.            
Portfolio      
%1)      
3708            
+644.06            
53938            +79.79 
%2)      3708      
      +1739.65      
94692            +215.64 
%... of course, I'd never trade with 100%, but these #'s 
illustrate my point better; 30000 should  produce the same 
results as -100 (100% of 30000)Here are the results for the 
same test at $3000 and -10 (10%  of 30000).  They are still 
significantly different:1)      
3708            
+65.80            
32445            + 8.15 
%2)      3708      
      +70.10      
      32605      
      + 8.68 %Do you think that 
the  difference between the integer and the floating point 
calculation of the percentage could account for this large of a 
difference?Best Regards to allNick Molchanoff--- 
In amibroker@xxxx, "Tomasz Janeczko" <amibroker@xxxx> wrote:> 
Hello,> > Nick wrote:> > > PositionSize) 
then, if you DO use PositionSize and set the number of > > 
shares to TotalEquity/Close, then the results of the two runs should 
> > be identical, but in all my tests, they are not.  I do 
not understand > > why this is so.  I must conclude 
that I am either suffering a > > misunderstanding, making an 
error, or there is a problem with > > PositionSize 
implementation.> First of all POSITION SIZE is expressed in DOLLARS 
not in number of shares.> > RTFM !> >Best 
regards,> Tomasz Janeczko> 
amibroker.comPost AmiQuote-related messages ONLY 
to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
href="">http://groups.yahoo.com/group/amiquote/messages/)Check 
group FAQ at: <A 
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Your use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service. 
Post AmiQuote-related messages ONLY to: 
amiquote@xxxxxxxxxxxxxxx (Web page: <A 
href="">http://groups.yahoo.com/group/amiquote/messages/)Check 
group FAQ at: <A 
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Your use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service. 
Post 
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
href="">http://groups.yahoo.com/group/amiquote/messages/)Check 
group FAQ at: <A 
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Your use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service.