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

RE: [amibroker] Re: How to use "positionscore" in this formula??



PureBytes Links

Trading Reference Links

I don't see PositionSize being set. If not, then it trades 100% of your account on one stock. You did set MaxOpenPositions, but that is not enough. Since you have 10 MaxOpenPositions you would need to at least set this to -10 (or 1000). Further, I think if you get, for example, 100 possible trades with 10 open positions, it's always going to trade from the top unless you have some priority set via PositionScore. It appears you do not.

 

Question: How can these two statements both be True?

"The net profit just goes downhill like a truck"

"I am not running out of money, it shows about 600K net profit…"

 

From HELP on PositionSize and partial on PositionScore. I have highlighted a couple of things in red.

SETTING UP POSITION SIZE

IMPORTANT: to enable more than one symbol to be traded you have to add PositionSize variable to your formula, so less than 100% of funds are invested in single security:

PositionSize = -25; // invest 25% of portfolio equity in single trade

or

PositionSize = 5000; // invest $5000 into single trade

There is a quite common way of setting both position size and maximum number of open positions so equity is spread equally among trades:

PosQty = 5; // You can define here how many open positions you want
SetOption("MaxOpenPositions", PosQty );
PositionSize = -100/PosQty; // invest 100% of portfolio equity divided
by max. position count

You can also use more sophisticated position sizing methods. For example volatility-based position sizing (Van Tharp-style):

PositionSize = -2 * BuyPrice/(2*ATR(10));

That way you are investing investing 2% of PORTFOLIO equity in the trade adjusted by BuyPrice/2*ATR factor.

USING POSITION SCORE

You can use new PositionScore variable to decide which trades should be entered if there are more entry signals on different securities than maximum allowable number of open positions or available funds. In such case AmiBroker will use the absolute value of PositionScore variable to decide which trades are preferred. See the code below. It implements simple MA crossover system, but with additional flavour of preferring entering trades on symbols that have low RSI value. If more buy signals occur than available cash/max. positions then the stock with lower RSI will be preferred. You can watch selection process if you backtest with "Detailed log" report mode turned on.

The code below includes also the example how to find optimum number of simultaneously open positions using new Optimization in Porfolio mode.

/*****
** REGULAR PORTFOLIO mode
** This sample optimization
** finds what is optimum num
ber of positions open simultaneously
**
****/

SetOption("InitialEquity", 20000 );
SetTradeDelays(1,1,1,1);
RoundLotSize = 1;

posqty = Optimize("PosQty", 4, 1, 20, 1 );
SetOption("MaxOpenPositions", posqty);

// desired position size is 100% portfolio equity
// divided
by PosQty positions

PositionSize = -100/posqty;

// The system is very simple...
// MA parameters could
be optimized too...
p1 = 10;
p2 = 22;
// simple MA crossover
Short=Cross( MA(C,p1) , MA(C,p2) );
Buy=Cross( MA(C,p2) , MA(C,p1) );
// always in the market
Sell=Short;
Cover=Buy;

// now additional score
// that is used to rank equities
// when there are more ENTRY signals that availa
ble
// positions/cash
PositionScore = 100-RSI(); // prefer stocks that have low RSI;

 

--

Terry

 

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Roy Ewing
Sent: Wednesday, December 07, 2005 18:43
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: How to use "positionscore" in this formula??

 

Terry,

 

Thanks for the tips.

 

To clarify, I do get an "occasional" "B", "C", and even a rare "E".

But it is clear when looking at the list that it keeps going back to

the beginning of the list at the "A's".

 

When I use POSITIONSCORE, the scoreing is working, ie I see a truly

"mixed" group of stocks.  The net profit just goes downhill like a truck.

 

Here are my settings:

 

SetOption("InitialEquity", 10000 );

SetOption("MaxopenPositions", 10);

SetOption("AllowPositionShrinking", True ); //No real impact

SetPositionSize(85,spsPercentOfEquity);

SetTradeDelays(1,1,0,0);//Do not use Short/Cover

ApplyStop(0,1,5,0,False,0);//Stop Loss at 5%

ApplyStop(2,2,3,0,False,0);//Trailing Stop at 3 Points

 

In AA I have all STOP SETTINGS DISABLED.

 

The effect of POSITIONSCORE on this is still puzzling.

No, I am not running out of money, it shows about 600K net profit

over the 5 years.  Throw in positionscore = 100 + mfi() and I get

$458.00 net profit over 5 years. (12/06/2000 - 12/06/2005)

 

Does not make sense unless I am simply missing something simple...just

why I asked the group!!

 

Thanks for the tips.

 

Roy

 

 

--- In amibroker@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxxx> wrote:

>

> I haven't followed your question closely so my advice may be off base,

> but it seems PositionSize may be your problem. If there are many

> possible trades the backtester will take the trades until you've spent

> all your money. Sounds like this is happening before you get out of the

> A's

>

> Try tightening your PositionScore rules to create less (hopefully

> better) opportunities and set PositionSize to some smaller fixed value

> like 1000 on a 100,000 portfolio (or -1 for 1% of portfolio) or similar

> ideas to see if you get trades farther down the alphabet. If you do, I

> was right :-)

>

> If you don't, well I can try harder.

> --

> Terry

> -----Original Message-----

> From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On

> Behalf Of sebastiandanconia

> Sent: Wednesday, December 07, 2005 11:48

> To: amibroker@xxxxxxxxxxxxxxx

> Subject: [amibroker] Re: How to use "positionscore" in this formula??

>

> A little more information, please.:)  Does the system test all

> the "A"s and then stop right before the "B"s?  Or is there a limit to

> the number of "A"s it tests, also?  When you use PositionScore, do

> you know that you're getting a full test on all the stocks, or does

> the system still stop testing additional stocks at a certain point,

> just farther into the alphabet?

>

> Not knowing all the details of what you're doing, here's a trouble-

> shooting idea.  Have you got a position-limit set in Automatic

> Analysis or in the system code itself?  Without PositionScore, there

> would be no ranking of the stocks, they'd simply be bought in

> alphabetical order from your watchlist as the "buy" signals click

> off.  If there's a position limit set, the system would just buy

> stocks up to the position limit and stop.  After those stocks got

> sold and a new "buy" signal comes up, the system will do the same

> thing over again, starting with the "A"s.  If there are enough stocks

> meeting the criteria to fill the portfolio from within the "A"s, your

> system would never get to the "B"s.  Anyway, that's just a place to

> start looking.

>

> Also, in my (our) experience, if a free system looks really great

> there's something wrong in the testing process, LOL!  In "Backtester

> Settings" under the "Trades" tab, see what the settings are.  My

> advice is to set them at "Open" with a 1-day trade delay, otherwise

> your system is taking trades on the day of the signal and not the

> NEXT day when you'd actually make the trade.  That will make your

> system returns artificially (and unrealistically) high.

>

> Sorry if I've gone over stuff that you already know.  Most of my

> mistakes are simple ones that I just didn't think of.:)

>

>

> Luck,

>

> Sebastian  

>

> --- In amibroker@xxxxxxxxxxxxxxx, "Roy Ewing" <slickums76@xxxx> wrote:

> >

> > I found a very good "system" in the AFL Library that produces very

> > good results for what I am trying to backtest.  Here it is, stripped

> > to the essentials:

> >

> > ---------------------------------------------------------------

> > //  Formula Name:    STD_STK Multi

> > //  Author/Uploader: Willem Jan

> >

> > STK=Optimize ("StK" , 14, 2, 18, 2);

> > STD=Optimize ("StD" ,16, 2, 18, 2);

> > pds =Optimize("pds", 10,2,18,2);

> >

> > Sell= Cross (EMA (StochD (STD),pds),EMA( StochK (STK),pds));

> > Buy= Cross (EMA(StochK (STK),pds),EMA( StochD (STD),pds));

> >

> > Filter=Buy OR Sell;

> >

> > Buy=ExRem(Buy,Sell);

> > Sell=ExRem(Sell,Buy);

> >

> > /* My Added POSITIONSCORE */

> > PositionScore = 100 + MFI(); //Also many others tried!

> >

> > ----------------------------------------------------------------

> >

> > The problem is that w/o "POSITIONSCORE", I never get out of

> the "A's"

> > during backtesting.

> >

> > I have had good results using "positionscore" with other formulas,

> but

> > I have tried over 30 combinations of different indicators here and

> the

> > results are MUCH WORSE.  Not only a little, but a lot worse.

> >

> > I can't believe the formula is so good that nothing will help it,

> and

> > the fact that I can't get out of the "A's" in my watchlist mean

> there

> > should be "better" trades.

> >

> > My watchlist is a list of "Optionable" stocks from TC2005,

> backtesting

> > for 5 years (about 600 stocks).

> >

> > Any ideas?

> >

> > I have emailed the author, but his email bounced.

> >

> > Thanks.

> >

> > Roy

> >

>

>

>

>

>

>

>

>

> Please note that this group is for discussion between users only.

>

> To get support from AmiBroker please send an e-mail directly to

> SUPPORT {at} amibroker.com

>

> For other support material please check also:

> http://www.amibroker.com/support.html

>

> Yahoo! Groups Links

>

 

 

 

 

 

 

------------------------ Yahoo! Groups Sponsor --------------------~-->

Try Online Currency Trading with GFT. Free 50K Demo. Trade

24 Hours. Commission-Free.

http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM

--------------------------------------------------------------------~->

 

Please note that this group is for discussion between users only.

 

To get support from AmiBroker please send an e-mail directly to

SUPPORT {at} amibroker.com

 

For other support material please check also:

http://www.amibroker.com/support.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:

    http://docs.yahoo.com/info/terms/

 

 



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS