I like apple’s approach and used aomega’s code for a start and added more to it. I used long only. What I get is very interesting. The CAGR is low mainly due to lack of opportunity/exposure, but if additional opportunity/exposure can be added (preferably some less-correlated ETFs) then it could probably be pushed to double-digit CAGR. It also has a high win %.
Here are the stats:
Initial capital 100000.00
Ending capital 164551.81
Net Profit 64551.81
Net Profit % 64.55 %
Exposure % 11.70
Net Risk Adjusted Return % 551.71
Annual Return % 4.26
Risk Adjusted Return % 36.45
—————————————
All trades 425
Avg. Profit/Loss 151.89
Avg. Profit/Loss % 0.85
Avg. Bars Held 6.97
—————————————
Winners 313 (73.65 %)
Total Profit 126975.19
Avg. Profit 405.67
Avg. Profit % 2.27
Avg. Bars Held 5.16
Max. Consecutive 30
Largest win 3878.40
# bars in largest win 2
—————————————
Losers 112 (26.35 %)
Total Loss -62423.38
Avg. Loss -557.35
Avg. Loss % -3.10 %
Avg. Bars Held 12.03
Max. Consecutive 6
Largest loss -3396.80
# bars in largest loss 29
—————————————
Max. trade drawdown -4212.90
Max. trade % drawdown -21.43 %
Max. system drawdown -24340.20
Max. system % drawdown -16.53 %
Recovery Factor 2.65
CAR/MaxDD 0.26
RAR/MaxDD 2.20
Profit Factor 2.03
Payoff Ratio 0.73
Standard Error 5783.82
Risk-Reward Ratio 0.78
Ulcer Index 1.88
Ulcer Performance Index -0.60
Sharpe Ratio of trades 1.46
K-Ratio 0.0491
—————————————-
And here is the code.
I ran it over 3000 bars, on a watchlist of SPY, IWM, QQQQ, VEU, EEM, GLD, DBC. I added basic position sizing.
***I did run an optimization over the entry and exit thresholds using CAR/MDD for the fitness function*** These results are NOT from using the optimal settings, but rather the settings that appeared the most robust on a 3D optimization graph.
//Step 1
PriceChange = abs(Close-Ref(Close, -1));
//Step 2
TenDayPriceChange = Close-Ref(Close, -10);
FirstRatio = (TenDayPriceChange / Sum(PriceChange, 10)) * -1;
//Step 3
TwoFiftyDayPriceChange = Close-Ref(Close, -250);
SecondRatio = (TwoFiftyDayPriceChange / Sum(PriceChange, 250));
//Step 4
Average = (FirstRatio + SecondRatio) / 2;
function PercentRank( Data, Periods ) //Ramon's PercentRank function
{
Count = 0;
for ( i = 1; i < Periods + 1 ; i++ )
{
Count = Count + IIf ( Ref( Data, 0 ) > Ref( Data, -i ), 1, 0 );
}
return 100 * Count / Periods;
}
RankPeriods = Param( "PercentRank Lookback Periods", 252, 5, 500, 5 );
CFE = PercentRank( Average, RankPeriods );
PosQty=7; // maximum of 7 positions
SetOption("InitialEquity", 100000);
SetTradeDelays( 0, 0, 0, 0 ); // all trades on the close
SetOption("MaxOpenPositions", PosQty);
PositionSize=-100/PosQty; // all positions sized equally
Ent=Optimize("Ent", 75, 5, 90, 5); // Entry threshold of 75
Ext=Optimize("Ext", 65, 5, 90, 5); // Exit threshold of 65
Entry=Ref(CFE,-1) < Ent AND CFE > Ent; // Entry cross above threshold
Exit=Ref(CFE,-1) > Ext AND CFE < Ext; // Exit cross below threshold
Buy=Entry;
Sell=Exit;
BuyPrice=Close;
SellPrice=Close;
|