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

Re: [amibroker] Code Question: buy best performing ticker of last 15 days



PureBytes Links

Trading Reference Links

hi
 
I fabricated something that doesn't make use of the barssince function since I didn't get it to work in a hurry. Code below does the following:
 
I 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).
 
rgds, ed
 
 
 
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
);
 
 
 
 
----- Original Message -----
Sent: Sunday, October 14, 2007 7:44 AM
Subject: [amibroker] Code Question: buy best performing ticker of last 15 days

How could I code this for backtesting in AB?

Buy on Friday the ticker symbol with the best performance of the last
15 trading days.

Sell 5 weeks later

Thanks, Samantha

__._,_.___

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

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




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___