Hello,
Some trades may be skipped due to settings/ insufficient
funds, see:
Best regards, Tomasz Janeczko amibroker.com
----- Original Message -----
Sent: Friday, March 17, 2006 12:24
AM
Subject: [amibroker] is something wrong
with this or is it a bug
I have a back test that does a good job. however when i rightlick on
results and select show arrows fo ractual trdes, i get arrows for trades that
were not traded at all.
i have attached a screen shot
http://xs72.xs.to/pics/06115/issueamibroker.jpg
Pl let me know what did i do wrong.
my script is
SetCustomBacktestProc ("");
if (Status("action")==actionPortfolio){
bo= GetBacktesterObject();
bo.backtest();
st=bo.GetPerformanceStats( 0);
// Expectancy calculation (the easy way)
// %Win * AvgProfit - %Los * AvgLos
// note that because AvgLos is already
negative
// in AmiBroker so we are adding values
instead of subtracting them
// we could also use simpler formula
NetProfit/NumberOfTrades
// but for the purpose of illustration we
are using more complex one :-)
expectancy = st.GetValue( "WinnersAvgProfit")*st.GetValue("WinnersPercent")/100 +
st.GetValue( "LosersAvgLoss")*st.GetValue("LosersPercent")/100;
// Here we add custom metric to backtest
report
bo.AddCustomMetric( "Expectancy
($)", expectancy );
}
//Buy 90 day breakouts
// Suersh
NumColumns = 5;
Period = 14;
// Determines trend direction using DMI indicators
PDIFilter= IIf(PDI(14)>MDI(14),1,0);
// make sure that the slope is going up and greater than 20
// New 3 month high has occurred in the last 5 days?
NewHighs = IIf(HHV(H,5)
>= HHV(H,60),
1,0);
//NewLows = LLV(L,5) <= LLV(L,40);
// Are moving averages lined up correctly? Close > 50 and 200
ma
BullishMAs = IIf(Close >= MA(C,200)
AND Close >= MA(C,50),
1,0);
//BearishMAs = IIf(MA(C,10) <= EMA(C,20) AND EMA(C,20) <= EMA(C,30),
1, 0);
/*
Column0 = ADX(period);
Column0Name = "ADX";
Column1 = IIf(PDIFilter AND NewHighs AND BullishMAs, 1, 0);
Column1Name = "Buy Signal";
Column2 = IIf(Column1 == 1, H + .125, 0);
Column2Name = "Buy Stop";
Column3 = IIf(MDIFilter AND NewLows AND BearishMAs, 1, 0);
Column3Name = "Sell Signal";
Column4 = IIf(Column3 == 1, L - .125, 0);
Column4Name = "Sell Stop";
*/
// Filter based on ADX > 20 (trending) and if buy or sell has
triggered
ADXval= IIf(ADX(14)>20,True,False);
//AND PDIfilter AND bullishMas AND (Close<5) AND (MA(V,30)>200000)
AND NewHighs) ;// (Column1 OR Column3);
_TRACE ("outsidee
buyubg");
//buynotdone=IIf(Buy=0,1,0);
//if (buynotdone AND NewHighs AND PDIFilter AND BullishMAs
){
_TRACE ("insude
buyubg");
//Buy= NewHighs AND PDIFilter AND BullishMAs ;
Buy= HHV(H,5)
>= HHV(H,60)
AND Close >= MA(C,200)
AND Close >= MA(C,50)
AND ADX(14)>20
AND MA(V,30)>200000
;
Sell = Close< Ref(Low,-1) AND Close<Ref(EMA(Close,9),-1) AND Buy;
SetTradeDelays ( 10,0, 10,
10 ) ;
//}
//Buy = Low <EMA(Close,9) * 105/100 AND Filter; // ADX(period) >=20
AND Column1;
//IIf(Buy=1,Sell = Close<Ref(Low,-1),False);
Buy = ExRem(
Buy, Sell );
Sell = ExRem(
Sell, Buy );
AddColumn (Buy,"Buy");
//AddColumn(Sell,"sell");
AddColumn (BuyPrice,"BuyPrice");
AddColumn (SellPrice,"SellPrice");
AddColumn (HHV(H,5) ,"HHV(H,5)
");
AddColumn (HHV(H,60),"HHVBars
");
SetCustomBacktestProc ("");
if (Status("action")==actionPortfolio){
bo= GetBacktesterObject();
bo.backtest();
st=bo.GetPerformanceStats( 0);
// Expectancy calculation (the easy way)
// %Win * AvgProfit - %Los * AvgLos
// note that because AvgLos is already
negative
// in AmiBroker so we are adding values
instead of subtracting them
// we could also use simpler formula
NetProfit/NumberOfTrades
// but for the purpose of illustration we
are using more complex one :-)
expectancy = st.GetValue( "WinnersAvgProfit")*st.GetValue("WinnersPercent")/100 +
st.GetValue( "LosersAvgLoss")*st.GetValue("LosersPercent")/100;
// Here we add custom metric to backtest
report
bo.AddCustomMetric( "Expectancy
($)", expectancy );
}
//Buy 90 day breakouts
// Suersh
NumColumns = 5;
Period = 14;
// Determines trend direction using DMI indicators
PDIFilter= IIf(PDI(14)>MDI(14),1,0);
// make sure that the slope is going up and greater than 20
// New 3 month high has occurred in the last 5 days?
NewHighs = IIf(HHV(H,5)
>= HHV(H,60),
1,0);
//NewLows = LLV(L,5) <= LLV(L,40);
// Are moving averages lined up correctly? Close > 50 and 200
ma
BullishMAs = IIf(Close >= MA(C,200)
AND Close >= MA(C,50),
1,0);
//BearishMAs = IIf(MA(C,10) <= EMA(C,20) AND EMA(C,20) <= EMA(C,30),
1, 0);
/*
Column0 = ADX(period);
Column0Name = "ADX";
Column1 = IIf(PDIFilter AND NewHighs AND BullishMAs, 1, 0);
Column1Name = "Buy Signal";
Column2 = IIf(Column1 == 1, H + .125, 0);
Column2Name = "Buy Stop";
Column3 = IIf(MDIFilter AND NewLows AND BearishMAs, 1, 0);
Column3Name = "Sell Signal";
Column4 = IIf(Column3 == 1, L - .125, 0);
Column4Name = "Sell Stop";
*/
// Filter based on ADX > 20 (trending) and if buy or sell has
triggered
ADXval= IIf(ADX(14)>20,True,False);
//AND PDIfilter AND bullishMas AND (Close<5) AND (MA(V,30)>200000)
AND NewHighs) ;// (Column1 OR Column3);
_TRACE ("outsidee
buyubg");
//buynotdone=IIf(Buy=0,1,0);
//if (buynotdone AND NewHighs AND PDIFilter AND BullishMAs
){
_TRACE ("insude
buyubg");
//Buy= NewHighs AND PDIFilter AND BullishMAs ;
Buy= HHV(H,5)
>= HHV(H,60)
AND Close >= MA(C,200)
AND Close >= MA(C,50)
AND ADX(14)>20
AND MA(V,30)>200000
;
Sell = Close< Ref(Low,-1) AND Close<Ref(EMA(Close,9),-1) AND Buy;
SetTradeDelays ( 10,0, 10,
10 ) ;
//}
//Buy = Low <EMA(Close,9) * 105/100 AND Filter; // ADX(period) >=20
AND Column1;
//IIf(Buy=1,Sell = Close<Ref(Low,-1),False);
Buy = ExRem(
Buy, Sell );
Sell = ExRem(
Sell, Buy );
AddColumn (Buy,"Buy");
//AddColumn(Sell,"sell");
AddColumn (BuyPrice,"BuyPrice");
AddColumn (SellPrice,"SellPrice");
AddColumn (HHV(H,5) ,"HHV(H,5)
");
AddColumn (HHV(H,60),"HHVBars
");
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 other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
YAHOO! GROUPS LINKS
|