Try this. It is an exploration that will use a portfolio of major exchange 
listed stocks filtered for volume and liquidity. Then it randomly selects 
stocks from the database and calculates the 1 day ROC. You can adjust the ROC 
to whatever period you want. Then just take the report into excel, count the up 
days, and average them. That should work for you, unless you can make it where 
AB will keep the count and average them for you. I'm not that good at .afl, but 
it would be neat to see how it is done.

MA20 = MA(C, 20);
AvgVol = MA(V, 20);
DolVol = MA20*AvgVol;
Cond1 = AvgVol > 100000 AND DolVol > 1000000;

RandomNum = mtRandom(); 
/* Adjust the number following RandomNum to decide what percentage is randomly 
selected*/
Filter = GroupID(0) == 1 AND Cond1 AND RandomNum>0.88; 
AddColumn( ROC(C, 1), "ROC");
AddColumn(DolVol, "DolVol");

--- In [email protected], "MD" <dimensi...@...> wrote:
>
> Hi,
> i am trying to do something that i think is rather simple, but having a heck 
> of a time doing so in Amibroker.  Basically i want to figure out the historic 
> percentage of the market closing 1 OR 2 days after any given day. the code is 
> below:
> 
> FixedDollarAmount = 1000;
> SetBacktestMode( backtestRegularRawMulti ); 
> buy = c; 
> sell = c > valuewhen(buy, c);
> applystop(stoptypeNBar, stopmodeBars, 2);
> PositionSize = FixedDollarAmount;
> 
> The system should buy EVERY day, and sell the next day if it's a higher close 
> or always exit on the 2nd day.
> 
> I want this to run as a backtest so i can see the percentage of win vs loss.  
> The problem is, it runs fine, but the percentages are way off when tested 
> against Yahoo's data from 1/1/1999 to current day.  I know the historic odds 
> of a close 1 or 2 days later is around 68%, however my backtest is returning 
> 51%.
> 
> Can anyone tell me see any issues with my script or what may be going on here?
> initially i thought the system may be running out of cash, as it uses the 
> default 100,000.  But that does not seem to be the case.
> 
> thank you.
>


Reply via email to