EasyTrader ArtNo 166
出擊日的型態有兩種。第一種相當明顯,在“出擊日的買進設定”這種情況下,即包含某一天的收盤價比前一天的最低價還低。這種日子也可以選取相對前3天到前8天的最低價計算。 出擊日的賣出設定剛好相反。此時你要找出某一個交易日,這一天的收盤價比前一天的最高價更高。我曾提過,有時候這會是一個有效的突破。然而,如果緊接著次日的價格朝出擊日的反方向走,而且交易價格比收盤下跌的出擊日最高價還要高,這就是一個重要的買進信號。同理,一個收盤上漲的出擊日亦即當日收盤價持續高於前一天的最高價,如果在出擊日次日的交易價格低於出擊日當天的最低點,這就是一個賣出信號。這這就是型態及基本原則應該有效的理由。我堅信在“市場應出現某種狀況而未出現”的情況下,事實強烈地證明我們應該根據新的信息進行交易。--- Larry Williams 短線交易秘訣
測試程式碼
Vars:Ref_L(1),Trend_L(5),Ref_S(1),Trend_S(5) ;
vars: BarNo(10),NBarL(29),NBarS(31),TradeProfit(0.057),TradeStopLoss(0.059) ;
Vars: ATRs_L(16.7),ATRs_S(2.9);
Vars:GaP_L(0),Gap_S(0);
vars: IsBalanceDay(False),MP(0),PF(0),PL(0);
MP = MarketPosition ;
if DAYofMonth(Date) > 14 and DAYofMonth(Date) < 22 and DAYofWeek(Date)= 3 then isBalanceDay = True else isBalanceDay =False ;
PF = AvgPrice*TradeProfit ;
PL = AvgPrice*TradeStopLoss ;
{ 收盤與最高或最低距離 }
Gap_L = Low[1]-Close ;
Gap_S = Close-High[1] ;
{ 多空條件設定 }
Condition1 = Gap_L > Close[1]*Ref_L/1000;
Condition2 = Gap_S > Close[1]*Ref_S/1000;
{ 多空趨勢判定 }
Condition3 = Close > Close[Trend_L] ;
Condition4 = Close < Close[Trend_S] ;
{ 下跌趨勢中突破高點買進 }
if {Close[1] > Open[1] and} Condition4 and Condition1 then Buy next bar at High+3 stop;
{ 上升趨勢中跌破低點賣出 }
if {Close[1] < Open[1] and} Condition3 and Condition2 then Sell next bar at Low-3 stop;
if ExitType = 1 then SetStopLoss(PL * BigPointValue) ;
if ExitType = 2 then Begin
SetStopLoss(PL * BigPointValue) ;
SetProfitTarget(PF * BigPointValue) ;
end;
if ExitType = 3 then Begin
if MP > 0 and BarsSinceEntry = NBarL then ExitLong next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then ExitShort next bar at Market ;
end;
if ExitType = 4 then Begin
SetStopLoss(PL * BigPointValue) ;
SetProfitTarget(PF * BigPointValue) ;
if MP > 0 and BarsSinceEntry = NBarL then Sell {ExitLong} next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then Buy {ExitShort} next bar at Market ;
end;
if ExitType = 5 then Begin
if ExitType = 2 then Begin
SetStopLoss(PL * BigPointValue) ;
SetProfitTarget(PF * BigPointValue) ;
end;
if ExitType = 3 then Begin
if MP > 0 and BarsSinceEntry = NBarL then ExitLong next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then ExitShort next bar at Market ;
end;
if ExitType = 4 then Begin
SetStopLoss(PL * BigPointValue) ;
SetProfitTarget(PF * BigPointValue) ;
if MP > 0 and BarsSinceEntry = NBarL then Sell {ExitLong} next bar at Market ;
if MP < 0 and BarsSinceEntry = NBarS then Buy {ExitShort} next bar at Market ;
end;
if ExitType = 5 then Begin
{Inputs: ATRs_L(3);}
Variables: PosHigh(0), ATRVal_L(0);
ATRVal_L = AvgTrueRange(10) * ATRs_L;
If BarsSinceEntry = 0 Then PosHigh = High;
If MarketPosition = 1 Then Begin
If High > PosHigh Then PosHigh = High;
ExitLong ("ATR") Next Bar at PosHigh - ATRVal_L Stop;
End else ExitLong ("ATR eb") Next bar at High - ATRVal_L Stop;
{Inputs: ATRs_S(3);}
Variables: PosLow(0), ATRVal_S(0);
ATRVal_S = AvgTrueRange(10) * ATRs_S;
If BarsSinceEntry = 0 Then PosLow = Low;
If MarketPosition = -1 Then Begin
If Low < PosLow Then PosLow = Low;
ExitShort ("ATR_1") Next Bar at PosLow + ATRVal_S Stop;
End else ExitShort ("ATR_1 eb") Next bar at Low + ATRVal_S Stop;
end;
Variables: PosLow(0), ATRVal_S(0);
ATRVal_S = AvgTrueRange(10) * ATRs_S;
If BarsSinceEntry = 0 Then PosLow = Low;
If MarketPosition = -1 Then Begin
If Low < PosLow Then PosLow = Low;
ExitShort ("ATR_1") Next Bar at PosLow + ATRVal_S Stop;
End else ExitShort ("ATR_1 eb") Next bar at Low + ATRVal_S Stop;
end;
if IsBalanceDay then setExitonClose ;
台指期 60分K 留倉 最近3000 個交易日 交易成本 1200
MagicQs085
沒有留言:
張貼留言