Hi gmorlosky, Here is a starting rotational system you can build on. It runs.
I didn't take time to notate it but I will be happy to try to answer any questions. [email protected] //ROTATIONAL Generic //IO: Fitness: CAR/MDD //IO: Save Cancelled: Y //IO: BegISDate: 01/03/2001 //IO: EndISDate: 05/27/2006 //IO: EndOSReal: 05/28/2006 //IO: EndOSReal: 02/06/2009 //OptimizerSetEngine("spso"); //OptimizerSetEngine("trib"); //OptimizerSetEngine("cmae"); EnableRotationalTrading(); a = Optimize("a", 15, 2, 20, 1); b = Optimize("b", 25, 10, 350, 2); hmb = Optimize("hmb", 0, 0, 30, 1); posqty = 1;//Optimize("PosQty", 1, 1, 2, 1); wrh = Optimize("wrh", 2, 1, 2, 1); SetBacktestMode( backtestrotational ); PositionSize = -100/PosQty; //Invest 100% of equity div by max. position count. SetOption("MaxOpenPositions", posqty ); SetOption("AllowPositionShrinking",True); SetOption("HoldMinBars",hmb); SetOption("WorstRankHeld", wrh ); SetOption("InitialEquity",100000); SetOption("MinShares",0); SetOption("InterestRate",0); SetOption("commissionmode",2);//1 = % of trade, 2 = $ per trade. SetOption("Commissionamount",14); SetTradeDelays(1,1,1,1); d = EMA(C, a) / EMA(C, b); g = IIf( d >= 0 ,d ,0); PositionScore = g; SetCustomBacktestProc(""); if(Status("action")==actionPortfolio) { bo=GetBacktesterObject(); bo.Backtest(); st = bo.GetPerformanceStats(0);//gets stats for all trades //chi squared with one degree of freedom, with the Yates correction wi=st.GetValue("WinnersQty"); Lo=st.GetValue("LosersQty"); Chi = (abs(wi-Lo)-1)^2/(wi+Lo); bo.AddCustomMetric( "Chi-Squared modif.: >10.83: very significant(1000:1), >6.64: significant (100:1) , >3.84: probably significant (20:1), <3.84: significance doubtful", Chi ); expectancy = st.GetValue("WinnersAvgProfit")*st.GetValue("WinnersPercent")/100 + st.GetValue("LosersAvgLoss") *st.GetValue("LosersPercent")/100; bo.AddCustomMetric( "Expectancy ($)", expectancy); AddToComposite(Foreign("~~~EQUITY","C"), "~~ROT Generic","X", atcFlagDeleteValues|atcFlagEnableInPortfolio); bo.AddCustomMetric( "Add Name","" ); bo.AddCustomMetric( "Add WL Number & Description","" ); } ~~~Equity = !Equity;
