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

Re: [amibroker] help with future leak problem in backtesting



PureBytes Links

Trading Reference Links

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();

Hi Andy!
Two statments  look  in  a future:
1. -> LastBarIndex = LastValue(BarIndex()); ----->>>   look in the future
2. ->LatestLowestClose = LastValue(LowestCloseWithinDaysConsidered); ----->>>   look in the future
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
So I modify the code:
Minprice = 2;
//LastBarIndex = LastValue(BarIndex()); ----->>>   look in the future
       LastBarIndex = BarCount -1;
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); ----->>>   look in the future

LatestLowestClose = 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=Sell=Short=Cover=0;
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*shapeHollowUpTriangle + Sell*shapeHollowUpTriangle;
PlotShapes(shape,IIf(Buy,colorYellow,colorDarkRed),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();
I ran backtester for 1/1/2007 & 1/31/2008 for all US Stocks
This is result (not Bad!!!):

Initial capital 100000.00 100000.00 100000.00
Ending capital 243186.60 243186.60 100000.00
Net Profit 143186.60 143186.60 0.00
Net Profit % 143.19 % 143.19 % 0.00 %
Exposure % 98.90 % 98.90 % 0.00 %
Net Risk Adjusted Return % 144.78 % 144.78 % N/A
Annual Return % 128.27 % 128.27 % 0.00 %
Risk Adjusted Return % 129.70 % 129.70 % N/A

All trades 162 162 (100.00 %) 0 (0.00 %)
 Avg. Profit/Loss 883.87 883.87 N/A
 Avg. Profit/Loss % 0.64 % 0.64 % N/A
 Avg. Bars Held 2.54 2.54 N/A

Winners 86 (53.09 %) 86 (53.09 %) 0 (0.00 %)
 Total Profit 421476.03 421476.03 0.00
 Avg. Profit 4900.88 4900.88 N/A
 Avg. Profit % 2.93 % 2.93 % N/A
 Avg. Bars Held 3.09 3.09 N/A
 Max. Consecutive 10 10 0
 Largest win 44651.72 44651.72 0.00
 # bars in largest win 1 1 0

Losers 76 (46.91 %) 76 (46.91 %) 0 (0.00 %)
 Total Loss -278289.43 -278289.43 0.00
 Avg. Loss -3661.70 -3661.70 N/A
 Avg. Loss % -1.95 % -1.95 % N/A
 Avg. Bars Held 1.91 1.91 N/A
 Max. Consecutive 6 6 0
 Largest loss -19183.64 -19183.64 0.00
 # bars in largest loss 1 1 0

Max. trade drawdown -19183.64 -19183.64 0.00
Max. trade % drawdown -11.41 % -11.41 % 0.00 %
Max. system drawdown -33237.74 -33237.74 0.00
Max. system % drawdown -14.35 % -14.35 % 0.00 %
Recovery Factor 4.31 4.31 N/A
CAR/MaxDD 8.94 8.94 N/A
RAR/MaxDD 9.04 9.04 N/A
Profit Factor 1.51 1.51 N/A
Payoff Ratio 1.34 1.34 N/A
Standard Error 23642.86 23642.86 0.00
Risk-Reward Ratio 5.74 5.74 N/A
Ulcer Index 6.95 6.95 0.00
Ulcer Performance Index 17.67 17.67 N/A
Sharpe Ratio of trades 1.55 1.55 0.00
K-Ratio 0.1081 0.1081 -1.#IND


Regards,Boris
















































 
__._,_.___

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

__,_._,___