Amibroker Crashing on Multiple system testing

Hello,

Happy new year!

I was trying to do a multiple system backtest for crypto using this code (took from here: Combining multiple strategies into one (ensemble strategies) - #2 by fxshrat)

here's the code

/// ############################# 1. create Symbol Clones ###################################
/// @link https://forum.amibroker.com/t/combining-multiple-strategies-into-one-ensemble-strategies/19232/2
// 1. In Analysis choose "Apply to: Current", "Range: All quotes", 
// 2. Choose "Periodicity" in backtester settings
// 3. Click "Scan" to clone symbol
// (As for giving a composite name don't forget starting with tilde!)
num_systems= 2;//number of systems / symbol clones
nm = Name();
appendix = "_System";
watchlist_backtest = ParamStr("Wathlist Name","Bactest_Demo");
if ( Status( "actionex" ) == actionScan ) {
	atcmode = atcFlagDefaults;
	for ( i = 1; i <= num_systems; i++ ) {
		indexname = "~" + nm + appendix + i;
		AddToComposite( Open, indexname, "O", atcmode );
		AddToComposite( High, indexname, "H", atcmode );
		AddToComposite( Low, indexname, "L", atcmode );
		AddToComposite( Close, indexname, "C", atcmode );
		AddToComposite( Volume, indexname, "V", atcmode );
		AddToComposite( OI, indexname, "I", atcmode );
	}		
	
	if (Status("stocknum")== 0){
	resultwl = CategoryCreate(watchlist_backtest, categoryWatchlist );
	wl_num_fr = GetOption("FilterIncludeWatchlist");
	List = CategoryGetSymbols( categoryWatchlist, wl_num_fr);	
	for ( i = 1; i <= num_systems; i++ ) {
	for (n = 0; (Symbol = StrExtract(List, n)) != "";  n++) 
	{
		indexname1 = "~"+ Symbol + appendix + i;            	
		CategoryAddSymbol(indexname1, categoryWatchlist, resultwl);
	}		
	}
	}	
}
/// ############################# 2. Run Postfolio backtest ###################################
/// @link https://forum.amibroker.com/t/combining-multiple-strategies-into-one-ensemble-strategies/19232/2
/// Multi system portfolio, single market
/// Put symbol clones to a WL first!
SetOption( "InitialEquity", 100000 );
SetOption("MaxOpenPositions", 3);
//SetOption( "FuturesMode", False ); //remove
SetOption( "MaxOpenPositions", num_systems ); // number of systems here
//SetOption( "AllowPositionShrinking", 1 ); //remove

wl_num = GetOption("FilterIncludeWatchlist");//
size = 50;
size_mode = spsPercentOfEquity;
if( Status( "actionex" ) == actionBacktest ) {
	if( InWatchList(wl_num) ) { // watchlist membership of symbol clones
		// enterlong = exitlong = 0;//remove
		// first symbol clone and system
		if ( StrFind( nm, "System1" ) )	{			
			
			SetOption("holdminbars",0); // Pairs strategy
			SetTradeDelays(0,0,0,0);
			SetOption("MaxOpenPositions", 2);

			downbar = C < O;
			upbar 	= C > O;

			SymbolClose		 =Foreign("ETHUSDT","C",fixup=1); //change symbol ETHUSDT
			SymbolOpen 		 =Foreign("ETHUSDT","O",fixup=1); //change symbol ETHUSDT

			Filter3 	= SymbolClose > SymbolOpen;
			Filter4 	= SymbolClose < SymbolOpen;

			buycondition = Filter3 AND downbar;
			exit = C > ref(H,-1);

			Buy = ref(buycondition,-1);
			Buyprice = open;
			Sell = ref(exit,-1);
			Sellprice = open;
			Buy = ExRem (Buy,Sell);
			
			SetPositionSize(25,size_mode);			
		}

		// second symbol clone and system
		if ( StrFind( nm, "System2" ) )	{
		
		SetOption("holdminbars",1); // Above VWAP RSI(2) Dip		
		SetTradeDelays(0,0,0,0); //
		SetOption("MaxOpenPositions", 1); 
	 	
		_SECTION_BEGIN("VWAP OHLC");
		Bars_so_far_today = 1 + BarsSince(Day() != Ref(Day(), -1));
		StartBar = ValueWhen(TimeNum() == 000000, BarIndex());
		TodayVolume = Sum(V, Bars_so_far_today);
		VWAP_OHLC = Sum((O + H + L + C) * V, Bars_so_far_today) / (4 * TodayVolume);
		Plot(VWAP_OHLC, "VWAP_OHLC", colorBlueGrey, styleThick);
		_SECTION_END();

		buycondition = C > VWAP_OHLC AND RSI(2)<10;
		sellcondition = C > Ref(H,-1);
		
		Buy = ref(buycondition,-1);
		BuyPrice = open;
		Sell = ref(sellcondition,-1);
		Sellprice = open;		
		Buy = ExRem (Buy,Sell);
			
		SetPositionSize(25,size_mode);		
		}
		
		SellPrice = CoverPrice = open;		
	}
}

Dummy = Optimize("Dummy", 1, 1, 1, 1);

since, I want to backtest using several symbols, I did create a watchlist.

then,

  1. I ran scan to get a symbol copy. ~BTCUSDT_System1, ~BTCUSDT_System2, ~ETHUSDT_System2, etc...
  2. made a new watchlist, from symbol copies.
  3. ran the backtest using the new watchlist.

It gets to like 92% completion, and then it crashes...

any ideas?

Thanks

Saying it "crashes" on the forum means absolutely nothing. It is like you told the doctor "I am sick" on the phone and hung up. Without seeing the patient, doctor cannot help. Neither doctor nor nobody else would have any "ideas".

Contact support at amibroker dot com with proper crash report as explained many times on the forum and in the docs.

http://www.amibroker.com/guide/x_bugrecovery.html

The full report contains crucial and 100% required data and without having them it is absolutely impossible to say anything.

1 Like