October 14, 2007
15 Day Performers Trading System
- AmiBrokerYahooGroup message #116148
- “Code Question: buy best performing ticker of last 15 days”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | //Buy on Friday the ticker symbol with the best performance of the last 15 trading days. //Sell 5 weeks later //It calculates the PositionScore on the Close at a thursday then it enters a trade at the Open on a friday AND closes this trade on the Open on a thrursday at least 22 bars after entry, //You will need the latest Version of Amibroker for this because of the break function. //Ed Pottasch and Samantha SetBarsRequired(10000,10000); SetOption("MaxOpenPositions", 1 ); PositionSize = -100; SetTradeDelays(0,0,0,0); PositionScore = IIf( Ref(ROC(C,15),-1) > 0, Ref(ROC(C,15),-1), 0); procedure sell_proc(Buy,Sellday){ global Sell; global SellPrice; SellPrice = 0; Sell = 0; // sell delay in bars selldelay = 22; for (i = 1; i < BarCount; i++) { if (Buy[ i ]) { for (j = i + selldelay; j < BarCount; j++) { if (Sellday[ j ]) { Sell[ j ] = 1; i = j; break; } } } } } Buy = DayOfWeek() == 5; BuyPrice = O; sell_proc(Buy,DayOfWeek() == 4); SellPrice = O; SetChartOptions(0, chartShowDates); GraphXSpace = 5; Plot(C,"C",1,64); PlotShapes(IIf(Buy,shapeUpArrow,0),colorWhite, layer = 0, yposition = BuyPrice, offset = 0 ); |
The idea works. Backtesting, using the above code on, for instance, a stock list Nasdaq 100, will give positive results. The results get even better if you divide your money in smaller portions like for instance
SetBarsRequired(10000,10000);
SetOption(”MaxOpenPositions”, 10 );
PositionSize = -10;
SetTradeDelays(0,0,0,0);
However, since it is a long only system you will see that in a down market it will give bad results. So you can add additional constraints only to buy when the market is trending upwards, like:
- Cf = Foreign(”!COMP”,”C”);
- Buy = DayOfWeek() == 5 and Cf > MA(Cf,100);
Just adding some ideas. In an upmarket the system makes around 25% per year without slippage. But slippage for such a system will be very small to negligable and can easily be avoided. The idea needs to be fine tuned so it will make money in any market. Also 25% per year is too little in my opinion. Need systems > 60% before they get interesting in my opinion.
- Trading idea by Samantha.
- Code and comments by Ed Pottasch.
To meet and greet Ed and Samantha visit http://finance.groups.yahoo.com/group/amibroker/
ATTACHED FILES
15 Day Performers: b_15dayperformers.afl (AFL formula file)
Filed by brian_z at 10:43 pm under Ideas (Experimental)

