Is there anyway to screen a list of stocks based on a criterion, rank
them and buy say the top five at certain point in time and then sell
them at a certain point in time?

I have the screening code worked out as I can filter for them and sort
to generate the list and the time based buys and sells are accurate as
well.  I just can't seem to piece both elements together into a
backtestable system.

I've tried positionscore and rotational trading and neither do what I
would like them to do.

Here is the filter

MPT_Period = Param("MPT Period", 50, 0, 500, 10);
Cdd = (HHV(C,MPT_Period) - C)/HHV(C,MPT_Period);
MaxDD = HHV(CDD,MPT_Period);
R2 = (Sum(Cdd*Cdd,MPT_Period))/(MPT_Period-1);
UI = sqrt(R2);
TR = Close/Ref(Close,-MPT_Period);
ANN = (exp(log(TR))-1);
UPI = (ANN - irate(5.1)/100)/UI;
Filter = 1;
AddTextColumn(FullName(),"Name",1.2);
AddColumn(UPI,"UPI");


Here is the buy and sell code

BuyDays = Param("# of BuyDays", 6, 1, 10, 1 );
SellDays = Param("# of SellDays", 2, -1, 15, 1 );
ShortDays = Param("# of ShortDays", 3, 0, 10, 1 );
m = Month()!=Ref(Month(),-1);
Buy = C > 1 AND Ref( m, BuyDays );
Sell = C > 1 AND Ref( m, -SellDays );
Short = Ref(m, - SellDays);
Cover = Ref(m, - (SellDays+ShortDays));

Tks

Reply via email to