Backtest generate no buy signals


I have been using Amibroker for quite some time and used it for a weekly system I have, the data I am using was from Metastock.

Since last weekend, I re-downloaded updated stock exchange data from Metastock. I see from Amibroker charts that the data look good. However, when I try to run the backtest with exact code I was using, there is no trade. Scan shows that there are only Sell signals, no Buy signals.

I then ran backtest on other systems, they have same issue, no buy signal generated. Detailed log shows no trade and no signal. Could someone enlighten me on what could be the cause of this? Could it be because of the data or Amibroker subscription issue? Appreciate any input.

Unfortunately your question isn't clear enough and does not provide all necessary details to give you an answer. Please follow this advice: How to ask a good question

You need to provide the formula

When scan displays no Buy signals, then there are no buy signals and obviously there would be no trades.
Start with something basic:

Buy = 1;
Sell = 1;

Hi Tomasz,

Thank you for your reply. I tried a basic buy and hold / crossover system, the system works fine.

This is a system template I have been using, it was generating signals for a long time until last week, it stopped generating buy signals. I added in Buy=1; Sell=1; in case it was the reason buy no luck.
There must be a mistake somewhere I made. Appreciate if you can take a look.

// Backtest Setup        
SetOption("InitialEquity", 250000);		// Adjust this to match your starting equity. Also adjust in Explore Code at bottom. **Set to 1,000,000 when backtesting**        
SetOption("MaxOpenPositions", 1000);		// Use this to limit the maximum number of trades you are willing to take        
SetOption("AccountMargin", 100);			// Adjust the level of leverage here. 100 = No Leverage, 50 = Up to $2 exposure for every $1 of equity        
SetOption("usecustombacktestproc", False);        
SetOption("CommissionMode",1);           	// Set the commission mode according to how your broker charges you commissions on each trade        
											// Mode 1 - percent of trade         
											// Mode 2 - $ per trade         
											// Mode 3 - $ per share/contract        
SetOption("CommissionAmount", 0.3);      	// Set commission amount here to match the commission mode you select above    
SetTradeDelays(1,1,1,1);                 	// Trades are delayed by 1 bar. Signals executed on the next bar after the signal        
BuyPrice = Open;                         	// Buy stocks at the open of the bar following the signal        
SellPrice = Open;                        	// Sell stocks at the open of the bar following the signal       
Buy = 1;
Sell = 1; 
RoundLotSize = 100;
Index 					= Foreign(".SZSC","C",True);        
MinimumTurnover 		= 30000000;			     
MAXTurnover 			= 150000000;			        
PercentPerTrade 		= 7; 						      
IndexFilterBars 		= 30;										     
StockHighFilterBars		= 50;									
StopLoss				= 9; 
ActiveBars				= 60;

EMALookBackPeriod		= 9;  

//ReentryDelay1			= Param("Reentry Delay", 0, 0, 20, 1);
//ProfitTakeDelay1		= Param("Profit Delay", 2, 0, 4, 1);
//PercentVolatilityPerTrade = Param("Volatility %", 0.5, 0.1,1,0.1);

// Trading Rules (Entry)      
LiquidityFilter 		= EMA(C*V,5) > MinimumTurnover AND EMA(C*V,5) < MAXTurnover;			// Require turnover  in a range      
IndexFilter 			= Index > EMA(Index,IndexFilterBars);   								// Index is above EMA(IndexFilterBars)        
StockHighFilter			= C == HHV(C,StockHighFilterBars);										// The close of the stock is the highest it has been in "StockHighFilterBars" weeks   
TradeBars				= BarIndex() - NullCount( C, 1 ) + 1;
TradeBarsFilter			= TradeBars > ActiveBars; 

//Buy =        LiquidityFilter AND IndexFilter AND StockHighFilter AND StrFind(FullName()," ORD A");   			//Original rules + Certain weeks of trading history
Buy =        LiquidityFilter AND IndexFilter AND StockHighFilter AND TradeBarsFilter AND StrFind(FullName()," ORD A");   			//Original rules + Certain weeks of trading history

PositionScore = MA(V,10)/V;																	//Take lowest relative volume trade
//PositionScore = (C-Ref(C,-10))/ATR(10);
//PositionScore = C/Ref(C,-26);

// Trading Rules (Exit)         
//Function for Simple Looping Trailing Stop - Only moves up until exit triggered then resets        
function TrailingStopClose(data) 										// This function defines the trailing stop        
stop[0] = data[0]; 														// Set first bar's stop value        
for (i = 1; i < BarCount; i++) 											// Loop through all other bars        
	if (Close[i] >= stop[i-1]) 											// If not stopped out yet        
	stop[i] = Max(data[i], stop[i-1]); 									// Set stop level for this bar        
	else 																// Else if is stopped out now        
	stop[i] = data[i]; 													// Reset to current value of stop data        
 } 																		// End of for loop        
return stop; 															// Return trailing stop array        
} 																		// End of function        

PercentTrail = StopLoss / 100;        
//TrailingStopExit = TrailingStopClose(C - TrailingMultiple * Ref(ATR(14),-1)); 
TrailingStopExit = TrailingStopClose(C-C*PercentTrail); 				// Call the TrailingStopClose function and tell it to use 'C-C*PercentTrail' as the trailing stop value        

ExitRule1 = TrailingStopExit < Ref(TrailingStopExit,-1);

ExitRule2 = Ref(EMA(C,EMALookBackPeriod),-1)>EMA(C,EMALookBackPeriod);  			//Security EMA trend down exit rule
//Sell =  TrailingStopExit < Ref(TrailingStopExit,-1) OR SellEmaTrendDown;  						//Test new added rule of security EMA rule	

//Sell =  ExitRule1;
Sell =  ExitRule1 OR ExitRule2;					

// COMPOUNDING 1       
SetPositionSize(PercentPerTrade,spsPercentOfEquity);					// % of Equity per trade 		

@iverson200, for a valid basic test the rules:

Buy = 1;
Sell = 1; 

should be placed UNDER your conditions of buy/sell otherwise, they are superseded.

In any case, to solve your problem I suggest employing a detailed exploration (breaking down all the complex rules - see an example) to see what are the values ​​you are actually using to define your "buy" (or sell) condition (there are multiple rules that could be the cause).
(A potential suspect is the "turnover" filter - perhaps your data provider has changed the way volume is reported).

Thanks for the help.

I used Buy =1 below the actual conditions to generate buy signals successfully.

I have isolated the different buy conditions, and figured out the reason was in one of the buy conditions as the stock name convention in Metastock datafeed has changed so the name in the string need to be changed accordingly.

To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?

Okay got it, thanks!

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.