PureBytes Links
Trading Reference Links
|
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 new report
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 tobuy.
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@xxxxxxxxxx
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 thefact
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't the following two situations produce identical
results?1) PositionSize = 30000; ( with equity set to 30000in
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.Hereare
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, thenthe
results of the two runs should > > be identical, but in allmy
tests, they are not. I do not understand > > why thisis
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.
|