Backtesting not returning any result

Wrote a simple code for back testing.
Though in scan mode, the code execution returns results, even we can see the signals drawn on the chart.
But while back testing, there is no result shown
a) when I ran as “Portfolio”.
b) when I ran as “Individual”, all the symbols are listed, except symbol name – everything is either blank or zero.

Even the report is showing no trade.

I am giving the code and the screenshots.

_SECTION_BEGIN("EMAXOVER");
SetChartOptions(0,chartShowArrows|chartShowDates);

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

ema20=EMA(C,20);
ema50=EMA(C,50);
Plot(ema20,"ema20",colorGreen,styleLine);
Plot(ema50,"ema50",colorred,styleLine);

//Buy Sell logic
Buy=Cross(ema20,ema50);
sell=Cross(ema50,ema20);

/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

//Buy sell price
BuyPrice=Close;
SellPrice=Close;

// Margin info
PositionSize=1000000;

SetTradeDelays(0,0,0,0);

_SECTION_END();

backtesting no results

1 Like

You have specified that you want each position to purchase $1M of the stock or other trading instrument. Do you have sufficient initial capital to cover that?

I would suggest going into the Analysis Settings, Report Tab, and selecting "Detailed Log" instead of "Trade List". AmiBroker will tell you what it's attempting to do and why it's not actually entering trades.

1 Like

Thank you.
Your suggestion helped in resolving the issue. Your help appreciated.

Anyone can help me I have them same problem. Though I open report data I can not understand why my back test show no many entry but no profit and loss, and just have long position? My code

Alpha1=2/(EMA(C,20)+1);
Alpha2=2/(EMA(C,40)+1);
EMA1[0]=C[0];
EMA2[0]=C[0];
for(i=1;i<BarCount-1;i++);
EMA1= Alpha1*C[i]+(1-Alpha1)*EMA1[i-1];
EMA2= Alpha2*C[i]+(1-Alpha2)*EMA2[i-1];
MACDD=EMA1-EMA2;
Buy=MACDD>0;
Sell=Buy - ATR(20);
Short=MACDD<0;
Cover=Short+ ATR(20);

ask%202 ![ask1|690x373]

Thank a lots.

ask1

Your code is completely wrong. Here are just a few of the problems:

  • You used a ';' (semicolon) at the end of your for() statement, so in fact your loop executes nothing
  • It appears you were were trying to calculate EMA1 and EMA2 inside the loop, but you are mixing arrays like Alpha1 with array elements like EMA1[i-1], so you are unlikely to generate the result you intended even if this code was inside the for() loop.
  • The Buy array is assigned boolean (1 or 0) values, which is correct. But then the Sell array is assigned Buy-ATR(10), so it contains numeric values less than 1. Since the Sell array is (nearly) always "true" (non-zero), you are generating a sell signal for every bar, which is why all your trades exit as soon as they enter.
  • I'm guessing that you might have been trying to assign a SellPrice based on the BuyPrice - ATR(10). However, you have not actually assigned any of the built-in price arrays, so you will just get whatever is specified in the Analysis Settings / Trades tab.
  • Same problem with Cover as with Sell

Please review this post: How do I learn AFL? as well as all the Tutorial topics in the AmiBroker Help files.

3 Likes

Thanks a million for detail answer. I am fixing it follow you instruction