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

Re: PositionSize Variable - Help - Inexplicable Results



PureBytes Links

Trading Reference Links

> While I'm no expert, and my most of understanding comes from R
(eading)TFM, 
> If you had gone to HELP>SEARCH and typed in POSITIONSIZE like I 
did, you would have seen:
> Position sizing(...)
> > C'mon Nick. You can do it. HELP>SEARCH is faster than email and 
usually more detailed.
> 
> Be a future AB guru.

CS,

You are correct; I should have picked up on that. Actually, 
I have read "TFM." -- several times in fact, and I did and do 
continue to use HELP>SEARCH "...like you did..." on a regular basis.
Additionally, I did see and did read the section you were kind enough 
to point out to me, ...several times.

But unfortunately, I fear it is now all too apparent that I have 
still not retained and integrated everything properly in spite of 
having read it several times, even with all the help I have received 
from the membership here.

I am shamed and humbled into silence. 

It really is embarassing to be shown how you missed the obvious, 
especially in a public forum.

Learning new things used to not be so difficult for me before my last 
stroke, in fact, I used to be a rather quick study. Things that used 
to come so quickly and easily for me now require hours of study and 
repetition. 

I say that not to make excuses for my thick-headedness, but it is the 
only explanation I can offer for my repeated failures to understand 
and get things right.

However, I am committed to continuing to learn. I will continue to 
do my best, and will endeavor to exhaust all local and private 
resources before consulting the group in the future. 

Thank You for your very clear response (once it was in my face in 
bold red HTML, I think I finally got it). And thank you for your vote 
of confidence in my abilities. A little encouragement goes a long 
way. I will strive toward that "AB Guru" status you mentioned.

Best Regards,

Nick Molchanoff


--- In amibroker@xxxx, "CS" <csaxe@xxxx> wrote:
> 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 
> 
> PositionSize = <size array>
> 
> Now you can control dollar amount or percentage of portfolio that 
is invested into the trade
> 
> 
> a.. positive number define (dollar) amount that is invested into 
the trade for example:
> 
> PositionSize = 1000; // invest $1000 in every trade
> 
> 
> b.. negative numbers -100..-1 define percentage: 
> -100 gives 100% of current portfolio size, 
> -33 gives 33% of available equity for example:
> 
> PositionSize = -50; /* always invest only half of the current 
equity */ 
> 
> 
> c.. dynamic sizing example:
> 
> 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 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;
> 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 are
> allocating 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
> 
> 
> 
> ----- Original Message ----- 
> From: n94612 
> To: amibroker@xxxx 
> 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't the 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 all
> 
> Nick 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.com
> 
> 
> Yahoo! Groups Sponsor 
> ADVERTISEMENT
> 
> 
> 
> 
> Post AmiQuote-related messages ONLY to: amiquote@xxxx 
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> 
> Check group FAQ at: 
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.