2013年11月21日 星期四

短線交易秘訣 - 每週交易日 Part 2 (程式碼)

EasyTrader ArtNo 056
延續 Part 1 這次改變想法,將週期調整為 150分K 不要在一開盤就進場來觀察 ,測試結果如下



與日線測試結果是有差異的!同樣我們也來仿上篇一樣作多空組合看看是否有改變



Oops !績效提升不少喔,讀者有興趣可以再試驗更短週期,說不定能找到更佳的操作週期

測試程式碼:
inputs:WeekdayL(1),WeekdayS(1),TradeProfit(0.03),TradeStopLoss(0.02)
,NdayLong(5),NdayShort(5),Type(1) ;
Vars:Tradeday(1),MP(0),isBalanceDay(false);

MP = MarketPosition ;

if DAYofMonth(Date) > 14 and DAYofMonth(Date) < 22 and DAYofWeek(Date)= 3 then isBalanceDay = True else isBalanceDay =False ;

if date <> date[1] then TradeDay = DAYofWeek(Date);

{ Long Trade }
if Type = 1 then Begin
   if TradeDay = WeekdayL and MP = 0 then Buy next bar at market ;
end;

{ Short Trade }
if Type = 2 then Begin
   if TradeDay = WeekdayS and MP = 0 then Sell next bar at market ;
end;

{ Long Trade and Short Trade}
if Type = 3 then Begin
   if TradeDay = WeekdayL and MP = 0 then Buy next bar at market ;
   if TradeDay = WeekdayS and MP = 0 then Sell next bar at market ;
end;

{ 進場後 N根Bar離場 }
If MP > 0 and BarsSinceEntry = NdayLong then ExitLong next bar at market ;
If MP < 0 and BarsSinceEntry = NdayShort then ExitShort next bar at market ;

{ 停損 / 停損 }
if MP > 0 and Low < EntryPrice*(1-TradeStopLoss) then
   ExitLong next bar at EntryPrice*(1-TradeStopLoss) stop ;

if MP > 0 and High > EntryPrice*(1+TradeProfit) then 
   ExitLong next bar at EntryPrice*(1+TradeProfit) stop ;

if MP < 0 and High > EntryPrice*(1+TradeStopLoss) then 
   ExitShort next bar at EntryPrice*(1+TradeStopLoss) stop ;

if MP < 0 and Low < EntryPrice*(1-TradeProfit) then 
   ExitShort next bar at EntryPrice*(1-TradeProfit) stop ;

if IsBalanceDay then SetExitOnClose ;



溫馨小提示
1.依據每週交易日的特性,它也可以成為一個不錯的濾網!
2.花一些時間作每月交易日的研究也不錯(Larry Williams 的另一個利器)

沒有留言:

張貼留言