All Trades Long Trades Short Trades Buy & Hold Net Profit ¥24,302.58 ¥59,841.86 ¥-35,539.28 ¥891,464.34 Profit per Bar ¥12.26 ¥44.72 ¥-55.19 ¥741.03 Total Commission ¥0.00 ¥0.00 ¥0.00 ¥0.00 Number of Trades 118 73 45 1 Average Profit ¥205.95 ¥819.75 ¥-789.76 ¥891,464.34 Average Profit % 2.53% 15.97% -19.28% 17,254.84% Average Bars Held 16.80 18.33 14.31 1,203.00 Winning Trades 41 32 9 1 Win Rate 34.75% 43.84% 20.00% 100.00% Gross Profit ¥87,983.19 ¥80,674.70 ¥7,308.49 ¥891,464.34 Average Profit ¥2,145.93 ¥2,521.08 ¥812.05 ¥891,464.34 Average Profit % 42.40% 49.38% 17.57% 17,254.84% Average Bars Held 30.00 32.13 22.44 1,203.00 Max Consecutive Winners 8 8 6 1 Losing Trades 77 41 36 0 Loss Rate 65.25% 56.16% 80.00% 0.00% Gross Loss ¥-63,680.61 ¥-20,832.84 ¥-42,847.77 ¥0.00 Average Loss ¥-827.02 ¥-508.12 ¥-1,190.22 ¥0.00 Average Loss % -18.71% -10.11% -28.49% 0.00% Average Bars Held 9.77 7.56 12.28 0.00 Max Consecutive Losses 16 15 14 0 Maximum Drawdown ¥-36,628.29 ¥-14,499.01 ¥-46,841.94 ¥-1,010,126.26 Maximum Drawdown Date 2004-09-16 2005-10-20 2008-06-23 2009-01-08 Profit Factor 1.38 3.87 0.17 正无穷大 Recovery Factor 0.66 4.13 0.00 0.88 Payoff Ratio 2.27 4.88 0.62 0.00 04年2月份买入000792盐湖钾肥,到08年最高时,长期持有能实现320倍收益,海龟只爬了5倍不到
WLD代码如下 using System; using System.Drawing; using WealthLab; using WealthLab.Indicators; namespace WealthLab.Strategies { public class MyStrategy : WealthScript { double N,L1, S1, L2, S2, L3, S3, L4, S4, SE, LE, LS, SS, FU, FD, Tick ; protected override void Execute() { int ChannelUp, ChannelDn, LongExit, ShrtExit, FailsafeUp, FailsafeDn; double BrktProf; int LeadBars, ATRParam, LstPsExBar; bool cond20; ChannelUp = 20 ; ChannelDn = 20 ; LongExit = 10 ; ShrtExit = 10 ; FailsafeUp = 55 ; FailsafeDn = 55 ; ATRParam = 20 ; PlotStops(); Tick = Bars.SymbolInfo.Tick; PlotSeries(PricePane, Highest.Series(High, ChannelUp) >> 1, Color.Green, LineStyle.Solid, 1); PlotSeries(PricePane, Lowest.Series(Low, ChannelDn ) >> 1, Color.Red, LineStyle.Dotted, 1); PlotSeries(PricePane, Highest.Series(High, FailsafeUp) >> 1, Color.Blue, LineStyle.Dotted, 1); PlotSeries(PricePane, Lowest.Series(Low, FailsafeDn) >> 1, Color.Fuchsia, LineStyle.Solid, 1); LeadBars =Math.Max(FailsafeUp, FailsafeDn); for(int bar = LeadBars; bar < Bars.Count; bar++) { SE = Highest.Series(High, ShrtExit)[bar]+ Tick ; LE = Lowest.Series(Low, LongExit)[bar]-Tick ; N = ATR.Series(Bars,ATRParam)[bar]; if (Positions.Count == 0 ) { L1 = Highest.Series(High, ChannelUp)[bar]; S1 = Lowest.Series(Low, ChannelDn)[bar]; L2 = L1 + 0.5 * N ; S2 = S1 - 0.5 * N ; L3 = L1 + 1.0 * N ; S3 = S1 - 1.0 * N ; L4 = L1 + 1.5 * N ; S4 = S1 - 1.5 * N ; BuyAtStop( bar+1,L1, "L1" ); ShortAtStop( bar+1,S1, "S1"); } else { if (ActivePositions.Count==3 ) { BuyAtStop( bar+1,L4, "L4" ); ShortAtStop( bar+1,S4, "S4"); } if(ActivePositions.Count==2 ) { BuyAtStop( bar+1,L3, "L3" ); ShortAtStop( bar+1,S3, "S3"); } if (ActivePositions.Count==1 ) { BuyAtStop( bar+1,L2, "L2" ); ShortAtStop( bar+1,S2, "S2"); } if (ActivePositions.Count==0 ) { BrktProf = 0 ; LstPsExBar = LastPosition.ExitBar; foreach( Position p in Positions ) if (p.ExitBar == LstPsExBar ) BrktProf += p.NetProfit; cond20 = (BrktProf < 0 ); if (cond20 == true) { L1 = Highest.Series(High, ChannelUp)[bar]; S1 = Lowest.Series(Low, ChannelDn)[bar]; L2 = L1 + 0.5 * N ; S2 = S1 - 0.5 * N ; L3 = L1 + 1.0 * N ; S3 = S1 - 1.0 * N ; L4 = L1 + 1.5 * N ; S4 = S1 - 1.5 * N ; BuyAtStop( bar+1,L1, "L1" ); ShortAtStop( bar+1,S1, "S1"); } else { FU = Highest.Series(High, FailsafeUp)[bar]; FD = Lowest.Series(Low, FailsafeDn)[bar]; L2 = FU + 0.5 * N ; S2 = FD - 0.5 * N ; L3 = FU + 1.0 * N ; S3 = FD - 1.0 * N ; L4 = FU + 1.5 * N ; S4 = FD - 1.5 * N ; BuyAtStop( bar+1,FU, "FU" ); ShortAtStop( bar+1,FD, "FD"); } } } for(int p = ActivePositions.Count - 1; p >= 0; p--) { Position pos = ActivePositions[p]; if(pos.PositionType==PositionType.Long) { LS=pos.EntryPrice-2*N; if( !SellAtStop( bar+1,pos, LS, "LongStop") ) SellAtStop( bar+1, pos, LE, "LongExit"); } else { SS=pos.EntryPrice+2*N; if( !CoverAtStop(bar+1, pos, SS, "ShortStop") ) CoverAtStop( bar+1, pos, SE, "ShortExit"); } } } } } } 各位大大,有没有优化的办法
Position Symbol Quantity Entry Date Entry Price Exit Date Exit Price Profit % Profit $ Bars Held Profit per Bar Entry Name Exit Name MAE % MFE % Short 600016.SS 907 2008-07-01 5.51 2008-07-08 6.17 -11.98 ¥-598.62 6 ¥-99.77 S1 ShortStop -11.98 4.17 Short 600016.SS 936 2008-07-03 5.34 2008-07-08 6.05 -13.30 ¥-664.56 4 ¥-166.14 S2 ShortStop -13.30 1.12 Long 600016.SS 794 2008-07-09 6.29 2008-07-16 5.63 -10.49 ¥-524.04 6 ¥-87.34 L1 LongStop -10.49 3.50 Long 600016.SS 773 2008-07-10 6.46 2008-07-15 5.82 -9.91 ¥-494.72 4 ¥-123.68 L2 LongStop -9.91 0.31 Short 600016.SS 899 2008-08-12 5.56 2008-08-20 6.11 -9.89 ¥-494.45 7 ¥-70.64 S1 ShortStop -9.89 3.06 Short 600016.SS 924 2008-08-13 5.41 2008-08-20 5.96 -10.17 ¥-508.20 6 ¥-84.70 S2 ShortStop -10.17 0.37 Short 600016.SS 927 2008-09-08 5.39 2008-11-13 4.62 14.29 ¥713.79 43 ¥16.60 S1 ShortExit -3.15 29.87 Short 600016.SS 952 2008-09-11 5.25 2008-11-13 4.62 12.00 ¥599.76 40 ¥14.99 S2 ShortExit -3.81 28.00 Short 600016.SS 976 2008-09-16 5.10 2008-11-13 4.62 9.41 ¥468.48 38 ¥12.33 S3 ShortExit -6.86 25.88 Short 600016.SS 1,002 2008-09-17 4.67 2008-09-22 5.45 -16.70 ¥-781.56 4 ¥-195.39 S4 ShortStop -16.70 12.21 Short 600016.SS 1,002 2008-09-24 4.96 2008-11-13 4.62 6.85 ¥340.68 32 ¥10.65 S4 ShortExit -6.85 23.79 Long 600016.SS 1,041 2009-02-04 4.80 2009-08-12 7.73 61.04 ¥3,050.13 128 ¥23.83 FU LongExit -6.46 84.79 Long 600016.SS 1,022 2009-02-05 4.89 2009-08-12 7.73 58.08 ¥2,902.48 127 ¥22.85 L2 LongExit -8.18 81.39 Long 600016.SS 1,006 2009-02-06 4.97 2009-03-02 4.52 -9.05 ¥-452.70 17 ¥-26.63 L3 LongStop -9.05 6.64 Long 600016.SS 990 2009-02-09 5.06 2009-02-20 4.66 -7.91 ¥-396.00 10 ¥-39.60 L4 LongStop -7.91 4.74 Long 600016.SS 1,006 2009-03-05 4.97 2009-08-12 7.73 55.53 ¥2,776.56 107 ¥25.95 L3 LongExit -8.05 78.47 Long 600016.SS 990 2009-03-09 5.05 2009-03-16 4.61 -8.71 ¥-435.60 5 ¥-87.12 L4 LongStop -8.71 0.79 Long 600016.SS 990 2009-03-24 5.05 2009-08-12 7.73 53.07 ¥2,653.20 96 ¥27.64 L4 LongExit -3.37 75.64 Short 600016.SS 732 2009-08-19 6.83 2009-08-21 7.52 -10.10 ¥-505.08 3 ¥-168.36 FD ShortStop -10.10 1.02 Short 600016.SS 739 2009-08-25 6.76 2009-10-12 7.14 -5.62 ¥-280.82 28 ¥-10.03 S1 ShortExit -5.62 10.36 Short 600016.SS 758 2009-08-28 6.59 2009-10-12 7.17 -8.80 ¥-439.64 25 ¥-17.59 S2 ShortStop -8.80 8.04 Short 600016.SS 778 2009-08-31 6.42 2009-09-14 7.08 -10.28 ¥-513.48 10 ¥-51.35 S3 ShortStop -10.28 5.61 Short 600016.SS 800 2009-09-01 6.07 2009-09-07 6.76 -11.37 ¥-552.00 5 ¥-110.40 S4 ShortStop -11.37 0.00 Short 600016.SS 778 2009-09-23 6.42 2009-10-12 7.07 -10.12 ¥-505.70 8 ¥-63.21 S3 ShortStop -10.12 1.87 Long 600016.SS 697 2009-10-14 7.17 Open Open 18.27 ¥913.07 25 ¥36.52 L1 0.00 20.64 Long 600016.SS 683 2009-10-15 7.38 Open Open 14.91 ¥751.30 24 ¥31.30 L2 -2.85 17.21 Long 600016.SS 671 2009-10-19 7.45 Open Open 13.83 ¥691.13 22 ¥31.42 L3 -0.27 16.11 Long 600016.SS 658 2009-10-20 7.59 Open Open 11.73 ¥585.62 21 ¥27.89 L4 -2.11 13.97 看看交易数据,居然有些仓位能够持有6个月,有的又很短。这龟有时耐心不错
a/b>(a+c)/(b+c), where a,b,c>0. It had reached a height of 43 times of the bottom value instead of 320 times.