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

[amibroker] help with future leak problem in backtesting



PureBytes Links

Trading Reference Links

Hi, 

I'm trying to backtest a system after reading Howard Bandy's book but 
have run into a future leak problem w/ the following code. 
Being a beginner in all this I"m not quite sure where the problem and 
how to fix it. Any help would be great. TIA.

-Andy

_SECTION_BEGIN("StockbeeTopMovers");

//http://stockbee.blogspot.com/2007/02/how-to-find-stock-which-makes-
1500-move.html
/* Pradeep Bonde
#  Use any of your favorite stock investing software. This example 
assumes excel based system.
# Calculate the Lowest Close for a stock in last 260 days. if a stock 
has less than 260 days data calculate Lowest Close for those many 
days.
# Calculate percent change from Lowest Close AND select stocks which 
had 100% plus growth
# Find the Highest price in the 100% move AND only take stocks which 
are within 25% of that Highest price.
# So this is your trading universe of stock which have made 
significant move of 100% OR more AND are as of today within 25% of 
the High during the move
# Use a significant one Day move scan on these stocks. e.g. Say a 5% 
move ( 100 * (C - C1) / C1) >= 5 AND V >= 1000 AND V > V1)
# Buy next Day with 1% risk AND stop below the Low of previous two 
days bar
# Trail with a stop
# if you get stopped Buy again on next breakout
# Enjoy your profits*/
// 100 * ((C + .01) - ( MINC260 + .01)) / (MINC260 + .01)>=100
// Price today >= .75*highest close during the 100% move.
Minprice = 2;
LastBarIndex = LastValue(BarIndex());
DaysConsidered = Min(260, LastBarIndex+1);
LowestCloseWithinDaysConsidered = LLV(C,DaysConsidered);
PercentGain = 100*((C + .01) - ( LowestCloseWithinDaysConsidered 
+ .01)) / (LowestCloseWithinDaysConsidered + .01);
PercentGainGE100 = PercentGain >= 100;
Volgreat = V > EMA(V,15);
AvgVol= EMA(V,15);
percentM = 0.03;



LatestLowestClose = LastValue(LowestCloseWithinDaysConsidered);
HighestCloseSinceLatestLowestClose = HighestSince((C == 
LatestLowestClose), C);
CloseWithin25PercentgeHighestClose = (C >= 
0.75*HighestCloseSinceLatestLowestClose);

// ( 100 * (C - C1) / C1) >= 5 AND V >= 1000 AND V > V1)

TodaysSignificantMove = ( 100 * (C - Ref(C, -1)) / Ref(C,-1)) >= 3 
AND V >= 1000000 AND Volgreat;


SetTradeDelays(1,0,0,0);
ApplyStop(stopTypeTrailing,stopModePercent,2,1);

Filterthis = PercentGainGE100 AND CloseWithin25PercentgeHighestClose 
AND TodaysSignificantMove AND C > Minprice;

Filter = Filterthis;
Buysignalclose = C >= 0.99*HighestCloseSinceLatestLowestClose AND 
Filterthis;


Buy = Filterthis;
Sell = C < 0.98*Buysignalclose;


//to plot the equity curve on the same graph
e=Equity();
//Plot(e,"equity",colorRed,styleLine|styleOwnScale);
shape = Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,colorDarkGreen,colorRed),O,IIf
(Buy,Low,High));

numberpositions = 1;
SetOption ("maxopenpositions",numberpositions);
PositionSize= -100/numberpositions;

//PositionScore
Lookback= 14;
PositionScore= ROC(C,Lookback);


Sell = ExRem(Sell,Buy);
//Buy = ExRem(Buy,Sell);


AddColumn( C, "Close", 1.2,IIf(Buy,colorGreen,colorRed) );
AddTextColumn( SectorID(1), "Sector name" );
AddTextColumn( IndustryID(1), "Industry name");
AddColumn (V, "Volume");
AddColumn (PercentGain,"PercentGain");
AddColumn (PositionScore,"PositionScore");
"PercentGain"  + " " + WriteVal(PercentGain);
//"NewLo"  + " " + WriteVal(NewLo);

_SECTION_END();



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
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/