===========原文內容==========
Hi Wen大
我把 tomorrow 改 Next bar 以100 分線回測3000日 只有 2007/6/1 ~2010/03 表現較好 , 其它績效曲線約是 5~10度向上的普通水平線。接觸程式約一年 , 還是菜鳥 ,Wen大的文章都會拿來練習 , 受用不少 !!
內文的加碼也可以使用的,獲利會提昇1.7倍,但MDD增一倍,出場方式還需多調整原始程式回測 3000日 --- 日線交易次數過低 < 50 次 , 30分線以下超過 1000 次,從進出點位觀察,此程式應用在趨勢盤是不錯的 ,盤整盤一樣容易被雙巴 !!
Eagle
原文程式碼 100 K線 TS2000i
inputs: Ceil(40),Flr(10),DeltaBar(50),initVarA(90) ;
{Additional input}
inputs:TStop1(0),StopB1(999),StopV1(0),TStop2(0),StopB2(999),StopV2(0),TStop3(0),StopB3(999),TStop4(0),StopV4(0);
inputs:TAdd3(0),AddB3(999),Alpha3(0),Beta3(0),TAdd4(0),AddV4(0),Alpha4(0),Beta4(0) ;
vars: X(0),Y(0),ZDelta(0),VarA(0),VarB(0),OldVarA(0),MP(0),OpLoss(0),OpPro(0),BottDay(0),PeakDay(0);
{Additional Variables}
Vars:Trigger(0),MaxReg(0) ,isBalanceDay(False);
Y=X;
X = Stddev(Close,DeltaBar) ;
if X <> 0 then ZDelta =(X-Y)/X else ZDelta = 0 ;
if CurrentBar = 1 then VarA = initVarA ;
OldVarA = VarA ;
VarA = OldVarA*(1+ZDelta) ;
VarA = MaxList(VarA,Flr) ;
VarA = MinList(VarA,Ceil) ;
VarB = VarA * 0.5 ;
Buy ("Go Long") next bar at Highest(High,VarA) stop ;
Sell ("Go Short") next bar at Lowest(Low,VarA) stop ;
ExitLong ("Exit Long") next bar at Lowest(Low,VarB) stop ;
ExitShort("Exit Short") next bar at Highest(High,VarB) stop ;
{Additional Trading}
{if BigPointValue <> 0 and EntryPrice <> 0 then Begin}
Trigger = iff((BigPointValue = 0 or EntryPrice = 0),0,(PositionProfit/BigPointValue)*100/EntryPrice) ;
MaxReg = iff((BigPointValue = 0 or EntryPrice =0),0,(MaxPositionProfit/BigPointValue)*100/EntryPrice) ;
{end;}
if TStop1 = 1 then Begin
if BarsSinceEntry >= StopB1 and Trigger < StopV1 then Begin
if MarketPosition = 1 then ExitLong ( "Stop Long1") next bar at Open Stop;
if MarketPosition = -1 then ExitShort ( "Stop Short1") next bar at Open Stop;
end;
end;
if TStop2 = 1 then Begin
if BarsSinceEntry >= StopB2 and Trigger < StopV2 then Begin
if MarketPosition = 1 then ExitLong ( "Stop Long2") next bar at Open Stop;
if MarketPosition = -1 then ExitShort ( "Stop Short2") next bar at Open Stop;
end;
end;
if TAdd3 = 1 then Begin
if BarsSinceEntry >= AddB3 and Trigger Cross over (Alpha3 + Beta3*BarsSinceEntry) then Begin
if MarketPosition = 1 then Buy ( "Add Long3") next bar at Open Stop;
if MarketPosition = -1 then Sell ("Add Short3") next bar at Open Stop;
end;
end;
if TStop3 = 1 then Begin
if BarsSinceEntry >= StopB3 and Trigger Cross under (Alpha3 + Beta3*BarsSinceEntry) then Begin
if MarketPosition = 1 then ExitLong ( "Stop Long3") next bar at Open Stop;
if MarketPosition = -1 then ExitShort ( "Stop Short3") next bar at Open Stop;
end;
end;
if TAdd4 = 1 then Begin
if MaxReg >= AddV4 and Trigger Cross over (Alpha4 + Beta4*MaxReg) then Begin
if MarketPosition = 1 then Buy ( "Add Long4") next bar at Open Stop;
if MarketPosition = -1 then Sell ("Add Short4") next bar at Open Stop;
end;
end;
if TStop4 = 1 then Begin
if MaxReg >= StopV4 and Trigger Cross under (Alpha4 + Beta4*MaxReg) then Begin
if MarketPosition = 1 then ExitLong ( "Stop Long4") next bar at Open Stop;
if MarketPosition = -1 then ExitShort ( "Stop Short4") next bar at Open Stop;
end;
end;
{End additional Trading}
MP = MarketPosition ;
OpLoss = MaxPositionLoss ;
OpPro = MaxPositionProfit ;
if OpLoss < OpLoss[1] and MP <> 0 then BottDay = BarsSinceEntry ;
if OpPro > OpPro[1] and MP <> 0 then PeakDay = BarsSinceEntry ;
OldVarA = VarA ;
VarA = OldVarA*(1+ZDelta) ;
VarA = MaxList(VarA,Flr) ;
VarA = MinList(VarA,Ceil) ;
VarB = VarA * 0.5 ;
Buy ("Go Long") next bar at Highest(High,VarA) stop ;
Sell ("Go Short") next bar at Lowest(Low,VarA) stop ;
ExitLong ("Exit Long") next bar at Lowest(Low,VarB) stop ;
ExitShort("Exit Short") next bar at Highest(High,VarB) stop ;
{Additional Trading}
{if BigPointValue <> 0 and EntryPrice <> 0 then Begin}
Trigger = iff((BigPointValue = 0 or EntryPrice = 0),0,(PositionProfit/BigPointValue)*100/EntryPrice) ;
MaxReg = iff((BigPointValue = 0 or EntryPrice =0),0,(MaxPositionProfit/BigPointValue)*100/EntryPrice) ;
{end;}
if TStop1 = 1 then Begin
if BarsSinceEntry >= StopB1 and Trigger < StopV1 then Begin
if MarketPosition = 1 then ExitLong ( "Stop Long1") next bar at Open Stop;
if MarketPosition = -1 then ExitShort ( "Stop Short1") next bar at Open Stop;
end;
end;
if TStop2 = 1 then Begin
if BarsSinceEntry >= StopB2 and Trigger < StopV2 then Begin
if MarketPosition = 1 then ExitLong ( "Stop Long2") next bar at Open Stop;
if MarketPosition = -1 then ExitShort ( "Stop Short2") next bar at Open Stop;
end;
end;
if TAdd3 = 1 then Begin
if BarsSinceEntry >= AddB3 and Trigger Cross over (Alpha3 + Beta3*BarsSinceEntry) then Begin
if MarketPosition = 1 then Buy ( "Add Long3") next bar at Open Stop;
if MarketPosition = -1 then Sell ("Add Short3") next bar at Open Stop;
end;
end;
if TStop3 = 1 then Begin
if BarsSinceEntry >= StopB3 and Trigger Cross under (Alpha3 + Beta3*BarsSinceEntry) then Begin
if MarketPosition = 1 then ExitLong ( "Stop Long3") next bar at Open Stop;
if MarketPosition = -1 then ExitShort ( "Stop Short3") next bar at Open Stop;
end;
end;
if TAdd4 = 1 then Begin
if MaxReg >= AddV4 and Trigger Cross over (Alpha4 + Beta4*MaxReg) then Begin
if MarketPosition = 1 then Buy ( "Add Long4") next bar at Open Stop;
if MarketPosition = -1 then Sell ("Add Short4") next bar at Open Stop;
end;
end;
if TStop4 = 1 then Begin
if MaxReg >= StopV4 and Trigger Cross under (Alpha4 + Beta4*MaxReg) then Begin
if MarketPosition = 1 then ExitLong ( "Stop Long4") next bar at Open Stop;
if MarketPosition = -1 then ExitShort ( "Stop Short4") next bar at Open Stop;
end;
end;
{End additional Trading}
MP = MarketPosition ;
OpLoss = MaxPositionLoss ;
OpPro = MaxPositionProfit ;
if OpLoss < OpLoss[1] and MP <> 0 then BottDay = BarsSinceEntry ;
if OpPro > OpPro[1] and MP <> 0 then PeakDay = BarsSinceEntry ;
0 留言:
張貼留言
如果有私人問題想請教,請透過網站右方『與站長聯絡』之表單,謝謝!