PureBytes Links
Trading Reference Links
|
Oliver,
You already have this ability.
Buy = C > MA(C, 5);
Sell = C < MA(C, 5);
PositionScore = IIF(Buy, C/MA(C,65) + 100, 0);//Add 100 so that all scores are positive.
Hope this helps,
Garyolivier_molongo <olivier_molongo@xxxxxxxxx> wrote:
Hi all,I want to do a backtesting that would allow me to buy each day the top N stocks ranked by a metric. I read this message but could not find the answer to my problem so I hope someboby can help me there.I tried to do this using the rotational mode. But it does not allow to use user define sell signals. Once I bought or shorted a stock I want to implement stops for my sell and cover orders. But the documentation of rotational mode says:"Exits are generated automatically when security's rank drops below "worst rank held". There is no real control over when exits happen except of setting low score to force exits. You can also set the score on any (at least one) security to value of scoreNoRotate to prevent rotation (so already open positions are kept). But this is global and does not give you individual
control."Is there a workaround for this? How can I truly buy the first N stocks and have individual control on my sell signals? Will this be implemented in a future version? Can you help on this Thomasz?Regards,Olivier--- In amibroker@xxxxxxxxxxxxxxx, "quanttrader714" <quanttrader714@xxxx> wrote:> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx>> wrote:> > > > > > Best regards,> > Tomasz Janeczko> > amibroker.com> > ----- Original Message ----- > > From: "quanttrader714" <quanttrader714@xxxx>> > To: <amibroker@xxxxxxxxxxxxxxx>> > Sent: Thursday, June 17, 2004 9:15 PM> > Subject: [amibroker] Re: Example of buying top N stocks ranked by> some metric - no takers?> > > > > > > After reviewing the portfolio-level backtesting
tutorial, I would> have> > > thought you could use a buy condition that's true for all stocks> and> > > then narrow the field to the 20 stocks with the highest stochd> with> > > MaxOpenPositions and PositionScore as in the following code. And> > > that the system tester would automatically link buys and sells,> > > where are the sells are based on your "custom AFL rule" (which I> > > arbitrarily made Sell=C<Ref(C,-3); here). But it doesn't seem to> work.> > > Does anyone know why?> > > > What you mean with "doesn't seem to work"> > Buy condition is indeed linked with sell.> > So it issues buy signal on very first bar for all symbols> > (only top N is bought according to highest PositonScore )> > then sell signals occur on different stocks depending on > >
Sell=C<Ref(C,-3);// > > sell condition.> > BUT THEN NEW "BUY" signals will appear only> > AFTER this SELL signal> > and then again next matching sell will be looked for.> > > > It works exactly like this and it is according to specs.> > > > Best regards,> > Tomasz Janeczko> > amibroker.com> > Here's what I mean by "doesn't seem to work." I ran the code I posted> (below) on the ND100 stocks for a 1 year period and got 4,673 trades> with 4,662 losers. With that many trades in one year over a list of> 100 stocks and with that many losers, the code doesn't seem to be> performing as intended. By intended, I mean to buy the top 20 stocks> with the highest stochd and sell them as Sell=C<Ref(C,-3); is met and> then buy more according to the highest stochd. And by "the code> doesn't seem to
be performing as intended" I *do not* mean Amibroker> is broken. Just that I thought from the documentation that the simple> code would do what I described but it doesn't seem to. Could you> please take a quick look at it?> > /*****> ** REGULAR PORTFOLIO mode> ****/> > SetOption("InitialEquity", 500000 );> SetTradeDelays(1,1,1,1);> SetOption("MaxOpenPositions", 20 ); // limit to 20;> PositionSize = -5;> Buy=C>0;//use a buy condition that is true for all stocks> Sell=C<Ref(C,-3);// your sell condition> // now use score to rank equities> PositionScore = StochD(14); // prefer stocks that have high stochd;Check AmiBroker web page at:http://www.amibroker.com/Check group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
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.
|