Matthias, will have a look at your questions in more detail tomorrow. But that crashing may be caused due to memory problems of your computer rather than an error in your code.
So if your systems are to be used in the 5-min timeframe try using a database that has its base time interval set to 5 minutes rather than ticks or 1-minute. So, if you have a data provider then simply create a new database using for the "base time interval" 5 minutes that solved a lot of my crash problems, regards, Ed From: Matthias Sent: Wednesday, September 08, 2010 8:55 PM To: [email protected] Subject: [amibroker] Backtest multiple systems across multiple timeframes Hi, thanks to the contribution of Ed Pottasch, supported by Bruce, I was able to dig a little deeper into Amibroker coding. Everybody who is interested in applying multiple systems on the same underlying simultaneously should look here, great piece of work: http://finance.groups.yahoo.com/group/AmiBroker-at/message/5349 Thanks Ed, thanks Bruce. Unfortunately, I stumbled across a couple of questions when backtesting multiple systems across different timeframes, hope someone can help, sorry for the post being a bit lenghty. Both systems are traded on the same underlying, in order to make things easier for AB (Which is a bit strange) I used the same set of data, just renamed it. both systems operate on the same timeframe, say 15mins. Question 1: I use the same variable "percentrisked" for both systems. Wanted to optimize for percent risked (only!, this is NOT shown in the example below), so to say capital allocated to each system for the smoothest equity curve, AB keeps crashing... Can I use the same variable name in each sub-section or are there limits? should I dedicated "percentrisked1" to system1 and "percentrisked2" to system2 only? I am not a programmer, but for my understanding, both variables are local, so AB should not be crashing...? Is using "Setoption" in this context appropriate or would it result in wrong values? if(Name()=="DAX_CFD_day1") { percentrisked=2.0; factor=Optimize("ATR-Factor",8.5,3,12,0.5); number=(percentrisked)/(ATR(14)*factor)*20; SetPositionSize(number, spsPercentOfEquity); SetOption("commissionmode",3); SetOption("Commissionamount",1.2); SetOption("AllowSameBarExit",True); SetOption("ActivateStopsImmediately",True); .....systemlogic here } if(Name()=="DAX_CFD_day") { percentrisked=Optimize("Bolli",0.6,0.5,1,0.1); sl=2;//Optimize("sl",2,2,2.5,0.5);//good:6 number=(percentrisked/(Ref(ATR(14),-1)*sl))*20; SetPositionSize(number, spsPercentOfEquity); SetOption("commissionmode",3); SetOption("Commissionamount",1.2); SetOption("AllowSameBarExit",True); SetOption("ActivateStopsImmediately",True); SetOption("FuturesMode",True); SetTradeDelays(1,1,1,1); Equity(1); ... systemlogic here } Question 2: Both systems above use 15min timeframe. Another system is using 1hr timeframe and is trading FX. I was not able to re-write the logic so that I could backtest the 3 systems with AA settings 15min timeframe. Any ideas? I do have about 8 systems, lowest timeframe is 5min, highest timeframe 4hrs. That would require a lot of "re-writing"... Am I alone with my "I have too many-systems" Problem or am I missing somehting? original logic in 1hr timeframe: percentrisked=0.007; sl=4.5; tp=2.5; number=((percentrisked)/(Ref(ATR(14),-0)*sl)); SetPositionSize(number,spsPercentOfEquity); SetOption("maxopenpositions",1); CCIperiod=Optimize("CCI",36,34,40,1); CCIthreshold=optimize("CCIthres",89,88,96,1); MAperiod=Optimize("maperiod",7,6,8,1); MA1= MA(C,MAperiod); MA2= MA(Ref(C,-2),MAperiod); CCIshort=CCI(CCIperiod)>=ccithreshold; CCIbuy= CCI(CCIperiod)<=-CCIthreshold; Buyok=Ref(CCIbuy,-1) AND Cross(MA1,MA2); Sellok=CCIshort; Shortok=Ref(CCIshort,-1) AND Cross(MA2,MA1); Coverok=CCIbuy; timestart=020000; window=170000 Check=timestart+window; timeok=TimeNum()>=timestart AND TimeNum()<=Check; Buy= Buyok AND timeok; Sell= Sellok; Short= Shortok AND timeok; Cover= Coverok; ApplyStop(stopTypeLoss,stopModePoint,sl*ATR(14)); //9 ApplyStop(stopTypeProfit,stopModePoint,tp*ATR(14)); //1.2 Equity(1); System2: percentrisked=0.007; sl=4.5; tp=2.5; SetOption("maxopenpositions",1); CCIperiod=Optimize("CCI",36,34,40,2); CCIthreshold=Optimize("CCIthres",97,88,96,2); MAperiod= Optimize("maperiod",7,7,9,1); TimeFrameSet(inHourly); MA1= MA(C,MAperiod); MA2= MA(Ref(C,-0),MAperiod); CCIhr= CCI(CCIperiod); ATR1= ATR(14); TimeFrameRestore(); number=((percentrisked)/(TimeFrameExpand(Ref(atr1,-0),inHourly)*sl)); SetPositionSize(number,spsPercentOfEquity); CCIshort=TimeFrameExpand(CCIhr,inHourly)>ccithreshold; CCIbuy= TimeFrameExpand(CCIhr,inHourly)<-CCIthreshold; Crossup=Cross(TimeFrameExpand(MA1,inHourly),TimeFrameExpand(Ref(MA2,-2),inHourly)); Crossdown=Cross(TimeFrameExpand(Ref(MA2,-2),inHourly),TimeFrameExpand(MA1,inHourly)); Buyok=Ref(CCIbuy,-5) AND Crossup; Sellok=CCIshort; Shortok=Ref(CCIshort,-5) AND Crossdown; Coverok=CCIbuy; timestart=20000; window=170000; Check=timestart+window; timeok=TimeNum()>=timestart AND TimeNum()<=Check; Buy=Buyok AND timeok; Sell= Sellok OR CCIexit; Short= Shortok AND timeok; Cover= Coverok OR CCIexit; ApplyStop(stopTypeLoss,stopModePoint,sl*TimeFrameExpand(Ref(ATR1,-1),inHourly)); ApplyStop(stopTypeProfit,stopModePoint,tp*TimeFrameExpand(Ref(ATR1,-1),inHourly)); Equity(1); Thanks a lot for your suggestions, Matthias
